You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2012/06/28 14:12:30 UTC

svn commit: r1354969 - in /maven/plugins/trunk/maven-deploy-plugin: ./ src/main/java/org/apache/maven/plugin/deploy/

Author: olamy
Date: Thu Jun 28 12:12:29 2012
New Revision: 1354969

URL: http://svn.apache.org/viewvc?rev=1354969&view=rev
Log:
[MDEPLOY-151] use maven-plugin-tools' java 5 annotations
Patch modified to use a released version
Submitted by Tony Chemit.

Modified:
    maven/plugins/trunk/maven-deploy-plugin/pom.xml
    maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java
    maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java
    maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java

Modified: maven/plugins/trunk/maven-deploy-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/pom.xml?rev=1354969&r1=1354968&r2=1354969&view=diff
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-deploy-plugin/pom.xml Thu Jun 28 12:12:29 2012
@@ -53,6 +53,7 @@ under the License.
 
   <properties>
     <mavenVersion>2.0.6</mavenVersion>
+    <mavenPluginPluginVersion>3.0</mavenPluginPluginVersion>
   </properties>
 
   <dependencies>
@@ -76,6 +77,13 @@ under the License.
       <artifactId>maven-artifact</artifactId>
       <version>${mavenVersion}</version>
     </dependency>
+    <!-- dependencies to annotations -->
+    <dependency>
+      <groupId>org.apache.maven.plugin-tools</groupId>
+      <artifactId>maven-plugin-annotations</artifactId>
+      <version>${mavenPluginPluginVersion}</version>
+      <scope>compile</scope>
+    </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
@@ -95,6 +103,47 @@ under the License.
     </dependency>
   </dependencies>
 
+  <build>
+
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-plugin-plugin</artifactId>
+          <version>${mavenPluginPluginVersion}</version>
+          <configuration>
+            <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+          </configuration>
+          <executions>
+            <execution>
+              <id>mojo-descriptor</id>
+              <phase>process-classes</phase>
+              <goals>
+                <goal>descriptor</goal>
+              </goals>
+            </execution>
+            <execution>
+              <id>help-goal</id>
+              <goals>
+                <goal>helpmojo</goal>
+              </goals>
+            </execution>
+          </executions>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-plugin-plugin</artifactId>
+        <version>${mavenPluginPluginVersion}</version>
+      </plugin>
+    </plugins>
+  </reporting>
+
   <profiles>
     <profile>
       <id>run-its</id>

Modified: maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java?rev=1354969&r1=1354968&r2=1354969&view=diff
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java (original)
+++ maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java Thu Jun 28 12:12:29 2012
@@ -32,6 +32,8 @@ import org.apache.maven.artifact.reposit
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Parameter;
 
 /**
  * @version $Id$
@@ -40,8 +42,8 @@ public abstract class AbstractDeployMojo
     extends AbstractMojo
 {
     /**
-     * @component
      */
+    @Component
     private ArtifactDeployer deployer;
 
     /**
@@ -49,6 +51,7 @@ public abstract class AbstractDeployMojo
      *
      * @component
      */
+    @Component
     protected ArtifactFactory artifactFactory;
 
     /**
@@ -56,44 +59,39 @@ public abstract class AbstractDeployMojo
      *
      * @component
      */
+    @Component
     ArtifactRepositoryFactory repositoryFactory;
 
     /**
      * Map that contains the layouts.
-     *
-     * @component role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
      */
+    @Component( role = ArtifactRepositoryLayout.class )
     private Map repositoryLayouts;
 
     /**
-     * @parameter default-value="${localRepository}"
-     * @required
-     * @readonly
      */
+    @Parameter( defaultValue = "${localRepository}", required = true, readonly = true )
     private ArtifactRepository localRepository;
 
     /**
      * Flag whether Maven is currently in online/offline mode.
-     * 
-     * @parameter default-value="${settings.offline}"
-     * @readonly
      */
+    @Parameter( defaultValue = "${settings.offline}", readonly = true )
     private boolean offline;
 
     /**
      * Parameter used to update the metadata to make the artifact as release.
-     * 
-     * @parameter expression="${updateReleaseInfo}" default-value="false"
      */
+    @Parameter( property = "updateReleaseInfo", defaultValue = "false" )
     protected boolean updateReleaseInfo;
 
     /**
      * Parameter used to control how many times a failed deployment will be retried before giving up and failing.
      * If a value outside the range 1-10 is specified it will be pulled to the nearest value within the range 1-10.
      *
-     * @parameter expression="${retryFailedDeploymentCount}" default-value="1"
      * @since 2.7
      */
+    @Parameter( property = "retryFailedDeploymentCount", defaultValue = "1" )
     private int retryFailedDeploymentCount;
 
     /* Setters and Getters */

Modified: maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java?rev=1354969&r1=1354968&r2=1354969&view=diff
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java (original)
+++ maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java Thu Jun 28 12:12:29 2012
@@ -30,6 +30,9 @@ import org.apache.maven.model.io.xpp3.Ma
 import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectHelper;
 import org.apache.maven.project.artifact.ProjectArtifactMetadata;
@@ -47,7 +50,6 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.Reader;
 import java.io.Writer;
-import java.lang.reflect.Type;
 import java.util.Iterator;
 import java.util.List;
 
@@ -55,178 +57,147 @@ import java.util.List;
  * Installs the artifact in the remote repository.
  *
  * @author <a href="mailto:aramirez@apache.org">Allan Ramirez</a>
- * @goal deploy-file
- * @requiresProject false
- * @threadSafe
  */
+@Mojo( name = "deploy-file", requiresProject = false, threadSafe = true )
 public class DeployFileMojo
     extends AbstractDeployMojo
 {
     /**
      * The default Maven project created when building the plugin
-     * 
-     * @parameter default-value="${project}"
-     * @required
-     * @readonly
      */
+    @Parameter( defaultValue = "${project}", required = true, readonly = true )
     private MavenProject project;
 
     /**
      * Used for attaching the source and javadoc jars to the project.
-     *
-     * @component
      */
+    @Component
     private MavenProjectHelper projectHelper;
 
     /**
      * GroupId of the artifact to be deployed.  Retrieved from POM file if specified.
-     *
-     * @parameter expression="${groupId}"
      */
+    @Parameter( property = "groupId" )
     private String groupId;
 
     /**
      * ArtifactId of the artifact to be deployed.  Retrieved from POM file if specified.
-     *
-     * @parameter expression="${artifactId}"
      */
+    @Parameter( property = "artifactId" )
     private String artifactId;
 
     /**
      * Version of the artifact to be deployed.  Retrieved from POM file if specified.
-     *
-     * @parameter expression="${version}"
      */
+    @Parameter( property = "version" )
     private String version;
 
     /**
-     * Type of the artifact to be deployed. 
+     * Type of the artifact to be deployed.
      * Retrieved from the &lt;packaging&gt element of the POM file if a POM file specified.
      * Defaults to the file extension if it is not specified via command line or POM.<br/>
-     * Maven uses two terms to refer to this datum: the &lt;packaging&gt; element 
+     * Maven uses two terms to refer to this datum: the &lt;packaging&gt; element
      * for the entire POM, and the &lt;type&gt; element in a dependency specification.
-     * 
-     *
-     * @parameter expression="${packaging}"
      */
+    @Parameter( property = "packaging" )
     private String packaging;
 
     /**
      * Description passed to a generated POM file (in case of generatePom=true)
-     *
-     * @parameter expression="${generatePom.description}"
      */
+    @Parameter( property = "generatePom.description" )
     private String description;
 
     /**
      * File to be deployed.
-     *
-     * @parameter expression="${file}"
-     * @required
      */
+    @Parameter( property = "file", required = true )
     private File file;
 
     /**
      * The bundled API docs for the artifact.
-     *
-     * @parameter expression="${javadoc}"
-     * @since 2.6
      */
+    @Parameter( property = "javadoc" )
     private File javadoc;
 
     /**
      * The bundled sources for the artifact.
-     *
-     * @parameter expression="${sources}"
-     * @since 2.6
      */
+    @Parameter( property = "sources" )
     private File sources;
 
     /**
      * Server Id to map on the &lt;id&gt; under &lt;server&gt; section of settings.xml
      * In most cases, this parameter will be required for authentication.
-     *
-     * @parameter expression="${repositoryId}" default-value="remote-repository"
-     * @required
      */
+    @Parameter( property = "repositoryId", defaultValue = "remote-repository", required = true )
     private String repositoryId;
 
     /**
-     * The type of remote repository layout to deploy to. Try <i>legacy</i> for 
+     * The type of remote repository layout to deploy to. Try <i>legacy</i> for
      * a Maven 1.x-style repository layout.
-     * 
-     * @parameter expression="${repositoryLayout}" default-value="default"
      */
+    @Parameter( property = "repositoryLayout", defaultValue = "default" )
     private String repositoryLayout;
 
     /**
      * URL where the artifact will be deployed. <br/>
      * ie ( file:///C:/m2-repo or scp://host.com/path/to/repo )
-     *
-     * @parameter expression="${url}"
-     * @required
      */
+    @Parameter( property = "url" )
     private String url;
 
     /**
      * Location of an existing POM file to be deployed alongside the main
      * artifact, given by the ${file} parameter.
-     * 
-     * @parameter expression="${pomFile}"
      */
+    @Parameter( property = "pomFile" )
     private File pomFile;
 
     /**
      * Upload a POM for this artifact.  Will generate a default POM if none is
      * supplied with the pomFile argument.
-     *
-     * @parameter expression="${generatePom}" default-value="true"
      */
+    @Parameter( property = "generatePom", defaultValue = "true" )
     private boolean generatePom;
 
     /**
      * Add classifier to the artifact
-     *
-     * @parameter expression="${classifier}";
      */
+    @Parameter( property = "classifier" )
     private String classifier;
 
     /**
      * Whether to deploy snapshots with a unique version or not.
-     *
-     * @parameter expression="${uniqueVersion}" default-value="true"
      */
+    @Parameter( property = "uniqueVersion", defaultValue = "true" )
     private boolean uniqueVersion;
 
     /**
      * The component used to validate the user-supplied artifact coordinates.
-     * 
-     * @component
      */
+    @Component
     private ModelValidator modelValidator;
 
     /**
      * A comma separated list of types for each of the extra side artifacts to deploy. If there is a mis-match in
      * the number of entries in {@link #files} or {@link #classifiers}, then an error will be raised.
-     *
-     * @parameter expression="${types}";
      */
+    @Parameter( property = "types" )
     private String types;
 
     /**
      * A comma separated list of classifiers for each of the extra side artifacts to deploy. If there is a mis-match in
      * the number of entries in {@link #files} or {@link #types}, then an error will be raised.
-     *
-     * @parameter expression="${classifiers}";
      */
+    @Parameter( property = "classifiers" )
     private String classifiers;
 
     /**
      * A comma separated list of files for each of the extra side artifacts to deploy. If there is a mis-match in
      * the number of entries in {@link #types} or {@link #classifiers}, then an error will be raised.
-     *
-     * @parameter expression="${files}"
      */
+    @Parameter( property = "files" )
     private String files;
 
     void initProperties()

Modified: maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java?rev=1354969&r1=1354968&r2=1354969&view=diff
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java (original)
+++ maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java Thu Jun 28 12:12:29 2012
@@ -26,6 +26,9 @@ import org.apache.maven.artifact.reposit
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.artifact.ProjectArtifactMetadata;
 
@@ -37,14 +40,12 @@ import java.util.regex.Pattern;
 
 /**
  * Deploys an artifact to remote repository.
- * 
+ *
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
  * @author <a href="mailto:jdcasey@apache.org">John Casey (refactoring only)</a>
  * @version $Id$
- * @goal deploy
- * @phase deploy
- * @threadSafe
  */
+@Mojo( name = "deploy", defaultPhase = LifecyclePhase.DEPLOY, threadSafe = true )
 public class DeployMojo
     extends AbstractDeployMojo
 {
@@ -52,31 +53,23 @@ public class DeployMojo
     private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile( "(.+)::(.+)::(.+)" );
 
     /**
-     * @parameter default-value="${project}"
-     * @required
-     * @readonly
      */
+    @Parameter( defaultValue = "${project}", required = true, readonly = true )
     private MavenProject project;
 
     /**
-     * @parameter default-value="${project.artifact}"
-     * @required
-     * @readonly
      */
+    @Parameter( defaultValue = "${project.artifact}", required = true, readonly = true )
     private Artifact artifact;
 
     /**
-     * @parameter default-value="${project.packaging}"
-     * @required
-     * @readonly
      */
+    @Parameter( defaultValue = "${project.packaging}", required = true, readonly = true )
     private String packaging;
 
     /**
-     * @parameter default-value="${project.file}"
-     * @required
-     * @readonly
      */
+    @Parameter( defaultValue = "${project.file}", required = true, readonly = true )
     private File pomFile;
 
     /**
@@ -84,25 +77,22 @@ public class DeployMojo
      * than those specified in &lt;distributionManagement&gt; ).
      * <br/>
      * Format: id::layout::url
-     * 
-     * @parameter expression="${altDeploymentRepository}"
      */
+    @Parameter( property = "altDeploymentRepository" )
     private String altDeploymentRepository;
-    
+
     /**
-     * @parameter default-value="${project.attachedArtifacts}
-     * @required
-     * @readonly
      */
+    @Parameter( defaultValue = "${project.attachedArtifacts}", required = true, readonly = true )
     private List attachedArtifacts;
-    
+
     /**
      * Set this to 'true' to bypass artifact deploy
-     *       
-     * @parameter expression="${maven.deploy.skip}" default-value="false"
+     *
      * @since 2.4
      */
-    private boolean skip;     
+    @Parameter( property = "maven.deploy.skip", defaultValue = "false" )
+    private boolean skip;
 
     public void execute()
         throws MojoExecutionException, MojoFailureException
@@ -221,7 +211,7 @@ public class DeployMojo
                 repo = repositoryFactory.createDeploymentArtifactRepository( id, url, repoLayout, true );
             }
         }
-        
+
         if ( repo == null )
         {
             repo = project.getDistributionManagementArtifactRepository();