maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dfabul...@apache.org
Subject svn commit: r689552 - /maven/sandbox/trunk/plugins/maven-downloader-plugin/src/main/java/org/apache/maven/plugins/GetMojo.java
Date Wed, 27 Aug 2008 18:35:28 GMT
Author: dfabulich
Date: Wed Aug 27 11:35:27 2008
New Revision: 689552

URL: http://svn.apache.org/viewvc?rev=689552&view=rev
Log:
support specifying an artifact with colons

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

Modified: maven/sandbox/trunk/plugins/maven-downloader-plugin/src/main/java/org/apache/maven/plugins/GetMojo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-downloader-plugin/src/main/java/org/apache/maven/plugins/GetMojo.java?rev=689552&r1=689551&r2=689552&view=diff
==============================================================================
--- maven/sandbox/trunk/plugins/maven-downloader-plugin/src/main/java/org/apache/maven/plugins/GetMojo.java
(original)
+++ maven/sandbox/trunk/plugins/maven-downloader-plugin/src/main/java/org/apache/maven/plugins/GetMojo.java
Wed Aug 27 11:35:27 2008
@@ -33,6 +33,7 @@
 import org.apache.maven.artifact.resolver.ArtifactResolver;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
 import org.codehaus.plexus.util.StringUtils;
 
 /**
@@ -76,19 +77,16 @@
 
     /**
      * @parameter expression="${groupId}"
-     * @required
      */
     private String groupId;
 
     /**
      * @parameter expression="${artifactId}"
-     * @required
      */
     private String artifactId;
 
     /**
      * @parameter expression="${version}"
-     * @required
      */
     private String version;
 
@@ -114,6 +112,11 @@
     private String remoteRepositories;
     
     /**
+     * @parameter expression="${artifact}"
+     */
+    private String artifact;
+    
+    /**
      * The remote repositories available for discovering dependencies and extensions as indicated
      * by the POM.
      * 
@@ -123,9 +126,19 @@
     private List pomRemoteRepositories;
     
     public void execute()
-        throws MojoExecutionException
+        throws MojoExecutionException, MojoFailureException
     {        
-        
+
+        if ( artifactId == null && artifact == null ) throw new MojoFailureException("You
must specify an artifact, e.g. -Dartifact=org.apache.maven.plugins:maven-downloader-plugin:1.0");
+        if ( artifactId == null )
+        {
+            String[] tokens = StringUtils.split( artifact, ":" );
+            if (tokens.length != 3 && tokens.length != 4) throw new MojoFailureException(
"Invalid artifact, you must specify groupId:artifactId:version[:packaging] " + artifact );
+            groupId = tokens[0];
+            artifactId = tokens[1];
+            version = tokens[2];
+            if (tokens.length == 4) packaging = tokens[3];
+        }
         Artifact toDownload = artifactFactory.createBuildArtifact( groupId, artifactId, version,
packaging );
         Artifact dummyOriginatingArtifact =
             artifactFactory.createBuildArtifact( "org.apache.maven.plugins", "maven-downloader-plugin",
"1.0", "jar" );



Mime
View raw message