maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From steph...@apache.org
Subject svn commit: r1143066 - /maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/GetMojo.java
Date Tue, 05 Jul 2011 13:57:33 GMT
Author: stephenc
Date: Tue Jul  5 13:57:32 2011
New Revision: 1143066

URL: http://svn.apache.org/viewvc?rev=1143066&view=rev
Log:
[MDEP-265] Add classifier option for dependency:get

Submitted by Salmaan Zaidi and Andreas Kohn

o Original Diff did not apply correctly

o Fixed formatting.

o Fixed behaviour when conflicting versions of specifying the classifier are used.

Modified:
    maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/GetMojo.java

Modified: maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/GetMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/GetMojo.java?rev=1143066&r1=1143065&r2=1143066&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/GetMojo.java
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/GetMojo.java
Tue Jul  5 13:57:32 2011
@@ -104,6 +104,13 @@ public class GetMojo
     private String version;
 
     /**
+     * The classifier of the artifact to download. Ignored if {@link #artifact} is used.
+     * @parameter expression="${classifier}"
+     * @since 2.3
+     */
+    private String classifier;
+
+    /**
      * The packaging of the artifact to download
      * @parameter expression="${packaging}" default-value="jar"
      */
@@ -129,7 +136,7 @@ public class GetMojo
     private String remoteRepositories;
 
     /**
-     * A string of the form groupId:artifactId:version[:packaging].
+     * A string of the form groupId:artifactId:version[:packaging][:classifier].
      * @parameter expression="${artifact}"
      */
     private String artifact;
@@ -160,20 +167,32 @@ public class GetMojo
         if ( artifactId == null )
         {
             String[] tokens = StringUtils.split( artifact, ":" );
-            if ( tokens.length != 3 && tokens.length != 4 )
+            if ( tokens.length < 3 && tokens.length > 5 )
             {
-                throw new MojoFailureException( "Invalid artifact, you must specify "
-                    + "groupId:artifactId:version[:packaging] " + artifact );
+                throw new MojoFailureException(
+                    "Invalid artifact, you must specify groupId:artifactId:version[:packaging][:classifier]
"
+                        + artifact );
             }
             groupId = tokens[0];
             artifactId = tokens[1];
             version = tokens[2];
-            if ( tokens.length == 4 )
+            if ( tokens.length >= 4 )
             {
                 packaging = tokens[3];
             }
+            if ( tokens.length == 5 )
+            {
+                classifier = tokens[4];
+            }
+            else
+            {
+                classifier = null;
+            }
         }
-        Artifact toDownload = artifactFactory.createBuildArtifact( groupId, artifactId, version,
packaging );
+
+        Artifact toDownload = classifier == null
+            ? artifactFactory.createBuildArtifact( groupId, artifactId, version, packaging
)
+            : artifactFactory.createArtifactWithClassifier( groupId, artifactId, version,
packaging, classifier );
         Artifact dummyOriginatingArtifact =
             artifactFactory.createBuildArtifact( "org.apache.maven.plugins", "maven-downloader-plugin",
"1.0", "jar" );
 



Mime
View raw message