maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From schu...@apache.org
Subject svn commit: r1745959 - in /maven/plugins/trunk/maven-dependency-plugin: ./ src/main/java/org/apache/maven/plugins/dependency/ src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ src/main/java/org/apache/maven/plugins/dependency/fromDep...
Date Sun, 29 May 2016 00:24:57 GMT
Author: schulte
Date: Sun May 29 00:24:57 2016
New Revision: 1745959

URL: http://svn.apache.org/viewvc?rev=1745959&view=rev
Log:
[MDEP-436] German umlauts in outputDirectory and destFileName getting garbled

o Applied patch with minor modifications to only set the encoding on ZIP
  type UnArchivers.

This closes #85


Modified:
    maven/plugins/trunk/maven-dependency-plugin/pom.xml
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java

Modified: maven/plugins/trunk/maven-dependency-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/pom.xml?rev=1745959&r1=1745958&r2=1745959&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-dependency-plugin/pom.xml Sun May 29 00:24:57 2016
@@ -75,6 +75,9 @@ under the License.
     <contributor>
       <name>Holger Mense</name>
     </contributor>
+    <contributor>
+      <name>Markus Karg</name>
+    </contributor>
   </contributors>
 
   <properties>

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java?rev=1745959&r1=1745958&r2=1745959&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java
Sun May 29 00:24:57 2016
@@ -37,6 +37,7 @@ import org.codehaus.plexus.archiver.Arch
 import org.codehaus.plexus.archiver.UnArchiver;
 import org.codehaus.plexus.archiver.manager.ArchiverManager;
 import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
+import org.codehaus.plexus.archiver.zip.ZipUnArchiver;
 import org.codehaus.plexus.components.io.fileselectors.IncludeExcludeFileSelector;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.ReflectionUtils;
@@ -176,10 +177,10 @@ public abstract class AbstractDependency
         }
     }
 
-    protected void unpack( Artifact artifact, File location )
+    protected void unpack( Artifact artifact, File location, String encoding )
         throws MojoExecutionException
     {
-        unpack( artifact, location, null, null );
+        unpack( artifact, location, null, null, encoding );
     }
 
     /**
@@ -191,15 +192,17 @@ public abstract class AbstractDependency
      *                 **&#47;*.properties</code>
      * @param excludes Comma separated list of file patterns to exclude i.e. <code>**&#47;*.xml,
      *                 **&#47;*.properties</code>
+     * @param encoding Encoding of artifact. Set {@code null} for default encoding.
      */
-    protected void unpack( Artifact artifact, File location, String includes, String excludes
)
+    protected void unpack( Artifact artifact, File location, String includes, String excludes,
String encoding )
         throws MojoExecutionException
     {
-        unpack( artifact, artifact.getType(), location, includes, excludes );
+        unpack( artifact, artifact.getType(), location, includes, excludes, encoding );
     }
-    
-    protected void unpack( Artifact artifact, String type, File location, String includes,
String excludes )
-                    throws MojoExecutionException
+
+    protected void unpack( Artifact artifact, String type, File location, String includes,
String excludes,
+                           String encoding )
+        throws MojoExecutionException
     {
         File file = artifact.getFile(); 
         try
@@ -228,6 +231,12 @@ public abstract class AbstractDependency
                 getLog().debug( "Found unArchiver by extension: " + unArchiver );
             }
 
+            if ( encoding != null && unArchiver instanceof ZipUnArchiver )
+            {
+                ( (ZipUnArchiver) unArchiver ).setEncoding( encoding );
+                getLog().info( "Unpacks '" + type + "' with encoding '" + encoding + "'."
);
+            }
+
             unArchiver.setUseJvmChmod( useJvmChmod );
 
             unArchiver.setIgnorePermissions( ignorePermissions );

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java?rev=1745959&r1=1745958&r2=1745959&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
Sun May 29 00:24:57 2016
@@ -89,7 +89,7 @@ public abstract class AbstractFromConfig
 
     /**
      * Collection of ArtifactItems to work on. (ArtifactItem contains groupId, artifactId,
version, type, classifier,
-     * outputDirectory, destFileName and overWrite.) See <a href="./usage.html">Usage</a>
for details.
+     * outputDirectory, destFileName, overWrite and encoding.) See <a href="./usage.html">Usage</a>
for details.
      *
      * @since 1.0
      */

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java?rev=1745959&r1=1745958&r2=1745959&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/ArtifactItem.java
Sun May 29 00:24:57 2016
@@ -95,6 +95,13 @@ public class ArtifactItem implements Dep
     private String overWrite;
 
     /**
+     * Encoding of artifact. Overrides default encoding.
+     *
+     * @parameter
+     */
+    private String encoding;
+
+    /**
      *
      */
     private boolean needsProcessing;
@@ -316,6 +323,24 @@ public class ArtifactItem implements Dep
     }
 
     /**
+     * @return Returns the encoding.
+     * @since 3.0
+     */
+    public String getEncoding()
+    {
+        return this.encoding;
+    }
+
+    /**
+     * @param encoding The encoding to set.
+     * @since 3.0
+     */
+    public void setEncoding( String encoding )
+    {
+        this.encoding = encoding;
+    }
+
+    /**
      * @return Returns the artifact.
      */
     public Artifact getArtifact()

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java?rev=1745959&r1=1745958&r2=1745959&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/fromConfiguration/UnpackMojo.java
Sun May 29 00:24:57 2016
@@ -126,7 +126,7 @@ public class UnpackMojo
         MarkerHandler handler = new UnpackFileMarkerHandler( artifactItem, this.markersDirectory
);
         
         unpack( artifactItem.getArtifact(), artifactItem.getType(), artifactItem.getOutputDirectory(),
-                artifactItem.getIncludes(), artifactItem.getExcludes() );
+                artifactItem.getIncludes(), artifactItem.getExcludes(), artifactItem.getEncoding()
);
         handler.setMarker();
     }
 

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java?rev=1745959&r1=1745958&r2=1745959&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/UnpackDependenciesMojo.java
Sun May 29 00:24:57 2016
@@ -69,6 +69,13 @@ public class UnpackDependenciesMojo
     private String excludes;
 
     /**
+     * Encoding of artifacts.
+     * @since 3.0
+     */
+    @Parameter( property = "mdep.unpack.encoding" )
+    private String encoding;
+
+    /**
      * Main entry into mojo. This method gets the dependencies and iterates
      * through each one passing it to DependencyUtil.unpackFile().
      *
@@ -89,7 +96,7 @@ public class UnpackDependenciesMojo
             destDir = DependencyUtil.getFormattedOutputDirectory( useSubDirectoryPerScope,
useSubDirectoryPerType,
                                                                   useSubDirectoryPerArtifact,
useRepositoryLayout,
                                                                   stripVersion, outputDirectory,
artifact );
-            unpack( artifact, destDir, getIncludes(), getExcludes() );
+            unpack( artifact, destDir, getIncludes(), getExcludes(), getEncoding() );
             DefaultFileMarkerHandler handler = new DefaultFileMarkerHandler( artifact, this.markersDirectory
);
             handler.setMarker();
         }
@@ -140,4 +147,22 @@ public class UnpackDependenciesMojo
     {
         this.includes = includes;
     }
+
+    /**
+     * @param encoding The encoding to set.
+     * @since 3.0
+     */
+    public void setEncoding( String encoding )
+    {
+        this.encoding = encoding;
+    }    
+
+    /**
+     * @return Returns the encoding.
+     * @since 3.0
+     */
+    public String getEncoding()
+    {
+        return this.encoding;
+    }
 }



Mime
View raw message