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/07/01 10:03:29 UTC

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

Author: olamy
Date: Sun Jul  1 08:03:27 2012
New Revision: 1355857

URL: http://svn.apache.org/viewvc?rev=1355857&view=rev
Log:
[MSOURCES-60] Use new annotations api.

Modified:
    maven/plugins/trunk/maven-source-plugin/pom.xml
    maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AbstractSourceJarMojo.java
    maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AggregatorSourceJarMojo.java
    maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceJarMojo.java
    maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceJarNoForkMojo.java
    maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceGeneratedJarMojo.java
    maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceJarMojo.java
    maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceJarNoForkMojo.java

Modified: maven/plugins/trunk/maven-source-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/pom.xml?rev=1355857&r1=1355856&r2=1355857&view=diff
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-source-plugin/pom.xml Sun Jul  1 08:03:27 2012
@@ -36,6 +36,11 @@ under the License.
   <name>Maven Source Plugin</name>
   <description>The Maven 2 Source Plugin creates a JAR archive of the source files of the current project.</description>
 
+  <properties>
+    <mavenVersion>2.0.9</mavenVersion>
+    <mavenPluginPluginVersion>3.0</mavenPluginPluginVersion>
+  </properties>
+
   <prerequisites>
     <maven>${mavenVersion}</maven>
   </prerequisites>
@@ -60,10 +65,6 @@ under the License.
     <url>http://jira.codehaus.org/browse/MSOURCES</url>
   </issueManagement>
 
-  <properties>
-    <mavenVersion>2.0.9</mavenVersion>
-  </properties>
-
   <dependencies>
     <dependency>
       <groupId>org.apache.maven</groupId>
@@ -85,6 +86,15 @@ under the License.
       <artifactId>maven-project</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.apache.maven</groupId>
       <artifactId>maven-archiver</artifactId>
@@ -125,6 +135,46 @@ 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-source-plugin/src/main/java/org/apache/maven/plugin/source/AbstractSourceJarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AbstractSourceJarMojo.java?rev=1355857&r1=1355856&r2=1355857&view=diff
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AbstractSourceJarMojo.java (original)
+++ maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AbstractSourceJarMojo.java Sun Jul  1 08:03:27 2012
@@ -25,6 +25,8 @@ import org.apache.maven.artifact.Depende
 import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectHelper;
 import org.codehaus.plexus.archiver.Archiver;
@@ -37,7 +39,6 @@ import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -57,78 +58,73 @@ public abstract class AbstractSourceJarM
      * List of files to include. Specified as fileset patterns which are relative to the input directory whose contents
      * is being packaged into the JAR.
      *
-     * @parameter
      * @since 2.1
      */
+    @Parameter
     private String[] includes;
 
     /**
      * List of files to exclude. Specified as fileset patterns which are relative to the input directory whose contents
      * is being packaged into the JAR.
      *
-     * @parameter
      * @since 2.1
      */
+    @Parameter
     private String[] excludes;
 
     /**
      * Exclude commonly excluded files such as SCM configuration. These are defined in the plexus
      * FileUtils.getDefaultExcludes()
      *
-     * @parameter default-value="true"
      * @since 2.1
      */
+    @Parameter( defaultValue = "true" )
     private boolean useDefaultExcludes;
 
     /**
      * The Maven Project Object
      *
-     * @parameter expression="${project}"
-     * @readonly
-     * @required
      */
+    @Parameter(defaultValue = "${project}", readonly = true, required = true)
     protected MavenProject project;
 
     /**
      * The Jar archiver.
-     *
-     * @component role="org.codehaus.plexus.archiver.Archiver" roleHint="jar"
      */
+    @Component( role = Archiver.class, hint = "jar" )
     private JarArchiver jarArchiver;
 
     /**
      * The archive configuration to use. See <a href="http://maven.apache.org/shared/maven-archiver/index.html">Maven
      * Archiver Reference</a>.
      *
-     * @parameter
      * @since 2.1
      */
+    @Parameter
     private MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
 
     /**
      * Path to the default MANIFEST file to use. It will be used if <code>useDefaultManifestFile</code> is set to
      * <code>true</code>.
      *
-     * @parameter default-value="${project.build.outputDirectory}/META-INF/MANIFEST.MF"
-     * @required
-     * @readonly
      * @since 2.1
      */
+    @Parameter( defaultValue = "${project.build.outputDirectory}/META-INF/MANIFEST.MF", readonly = true,
+                required = true )
     private File defaultManifestFile;
 
     /**
      * Set this to <code>true</code> to enable the use of the <code>defaultManifestFile</code>. <br/>
      *
-     * @parameter default-value="false"
      * @since 2.1
      */
+    @Parameter( defaultValue = "false" )
     private boolean useDefaultManifestFile;
 
     /**
      * Specifies whether or not to attach the artifact to the project
-     *
-     * @parameter expression="${attach}" default-value="true"
      */
+    @Parameter( property = "attach", defaultValue = "true" )
     private boolean attach;
 
     /**
@@ -136,48 +132,43 @@ public abstract class AbstractSourceJarM
      * can be convenient if your project includes large resources, such as
      * images, and you don't want to include them in the sources-jar.
      *
-     * @parameter expression="${source.excludeResources}" default-value="false"
      * @since 2.0.4
      */
+    @Parameter( property = "source.excludeResources", defaultValue = "false" )
     protected boolean excludeResources;
 
     /**
      * Specifies whether or not to include the POM file in the sources-jar.
      *
-     * @parameter expression="${source.includePom}" default-value="false"
      * @since 2.1
      */
+    @Parameter( property = "source.includePom", defaultValue = "false" )
     protected boolean includePom;
 
     /**
      * Used for attaching the source jar to the project.
-     *
-     * @component
      */
+    @Component
     private MavenProjectHelper projectHelper;
 
     /**
      * The directory where the generated archive file will be put.
-     *
-     * @parameter default-value="${project.build.directory}"
      */
+    @Parameter( defaultValue = "${project.build.directory}" )
     protected File outputDirectory;
 
     /**
      * The filename to be used for the generated archive file.
      * For the source:jar goal, "-sources" is appended to this filename.
      * For the source:test-jar goal, "-test-sources" is appended.
-     *
-     * @parameter default-value="${project.build.finalName}"
      */
+    @Parameter( defaultValue = "${project.build.finalName}" )
     protected String finalName;
 
     /**
      * Contains the full list of projects in the reactor.
-     *
-     * @parameter expression="${reactorProjects}"
-     * @readonly
      */
+    @Parameter( defaultValue = "${reactorProjects}", readonly = true )
     protected List reactorProjects;
 
     /**
@@ -185,18 +176,18 @@ public abstract class AbstractSourceJarM
      * always be created.  If set to false, the jar will only be created when the
      * sources are newer than the jar.
      *
-     * @parameter expression="${source.forceCreation}" default-value="false"
      * @since 2.1
      */
+    @Parameter( property = "source.forceCreation", defaultValue = "false" )
     private boolean forceCreation;
 
     /**
      * A flag used to disable the source procedure. This is primarily intended for usage from the command line to
      * occasionally adjust the build.
      *
-     * @parameter expression="${source.skip}" default-value="false"
      * @since 2.2
      */
+    @Parameter( property = "source.skip", defaultValue = "false" )
     private boolean skipSource;
 
     // ----------------------------------------------------------------------
@@ -343,7 +334,7 @@ public abstract class AbstractSourceJarM
             }
         }
 
-        for ( String s : getSources( p ))
+        for ( String s : getSources( p ) )
         {
 
             File sourceDirectory = new File( s );

Modified: maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AggregatorSourceJarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AggregatorSourceJarMojo.java?rev=1355857&r1=1355856&r2=1355857&view=diff
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AggregatorSourceJarMojo.java (original)
+++ maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/AggregatorSourceJarMojo.java Sun Jul  1 08:03:27 2012
@@ -20,23 +20,24 @@ package org.apache.maven.plugin.source;
  */
 
 import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
 
 /**
  * Aggregate sources for all modules in an aggregator project.
  *
  * @version $Id$
- * @goal aggregate
- * @phase package
- * @aggregator
- * @execute phase="generate-sources"
  * @since 2.0.3
- * @threadSafe
- * 
  */
+@Mojo( name = "aggregate", defaultPhase = LifecyclePhase.PACKAGE, aggregator = true, threadSafe = true )
+@Execute( phase = LifecyclePhase.GENERATE_SOURCES )
 public class AggregatorSourceJarMojo
     extends SourceJarMojo
 {
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     public void execute()
         throws MojoExecutionException
     {

Modified: maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceJarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceJarMojo.java?rev=1355857&r1=1355856&r2=1355857&view=diff
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceJarMojo.java (original)
+++ maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceJarMojo.java Sun Jul  1 08:03:27 2012
@@ -19,17 +19,19 @@ package org.apache.maven.plugin.source;
  * under the License.
  */
 
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+
 /**
  * This plugin bundles all the sources into a jar archive.
  *
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
- * @goal jar
- * @phase package
- * @execute phase="generate-sources"
  * @since 2.0.3
- * @threadSafe
  */
+@Mojo( name = "jar", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true )
+@Execute( phase = LifecyclePhase.GENERATE_SOURCES )
 public class SourceJarMojo
     extends SourceJarNoForkMojo
 {

Modified: maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceJarNoForkMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceJarNoForkMojo.java?rev=1355857&r1=1355856&r2=1355857&view=diff
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceJarNoForkMojo.java (original)
+++ maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/SourceJarNoForkMojo.java Sun Jul  1 08:03:27 2012
@@ -20,6 +20,9 @@ package org.apache.maven.plugin.source;
  */
 
 import org.apache.maven.model.Resource;
+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 java.util.Collections;
@@ -32,18 +35,16 @@ import java.util.List;
  *
  * @author pgier
  * @version $Id$
- * @goal jar-no-fork
- * @phase package
- * @threadSafe
  * @since 2.1
  */
+@Mojo( name = "jar-no-fork", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true )
 public class SourceJarNoForkMojo
     extends AbstractSourceJarMojo
 {
     /**
-     * @parameter expression="${maven.source.classifier}" default-value="sources"
      * @since 2.2
      */
+    @Parameter( property = "maven.source.classifier", defaultValue = "sources" )
     protected String classifier;
 
     /**

Modified: maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceGeneratedJarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceGeneratedJarMojo.java?rev=1355857&r1=1355856&r2=1355857&view=diff
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceGeneratedJarMojo.java (original)
+++ maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceGeneratedJarMojo.java Sun Jul  1 08:03:27 2012
@@ -19,16 +19,17 @@ package org.apache.maven.plugin.source;
  * under the License.
  */
 
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+
 /**
  * This plugin bundles all the test sources into a jar archive.
  *
- * @goal generated-test-jar
- * @phase package
- * @execute phase="generate-test-sources"
  * @since 2.2
- * @threadSafe
- * 
  */
+@Mojo( name = "generated-test-jar", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true )
+@Execute( phase = LifecyclePhase.GENERATE_TEST_SOURCES )
 public class TestSourceGeneratedJarMojo
     extends TestSourceJarNoForkMojo
 {

Modified: maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceJarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceJarMojo.java?rev=1355857&r1=1355856&r2=1355857&view=diff
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceJarMojo.java (original)
+++ maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceJarMojo.java Sun Jul  1 08:03:27 2012
@@ -19,16 +19,17 @@ package org.apache.maven.plugin.source;
  * under the License.
  */
 
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+
 /**
  * This plugin bundles all the test sources into a jar archive.
  *
- * @goal test-jar
- * @phase package
- * @execute phase="generate-sources"
  * @since 2.0.3
- * @threadSafe
- * 
  */
+@Mojo( name = "test-jar", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true )
+@Execute( phase = LifecyclePhase.GENERATE_SOURCES )
 public class TestSourceJarMojo
     extends TestSourceJarNoForkMojo
 {

Modified: maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceJarNoForkMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceJarNoForkMojo.java?rev=1355857&r1=1355856&r2=1355857&view=diff
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceJarNoForkMojo.java (original)
+++ maven/plugins/trunk/maven-source-plugin/src/main/java/org/apache/maven/plugin/source/TestSourceJarNoForkMojo.java Sun Jul  1 08:03:27 2012
@@ -20,6 +20,9 @@ package org.apache.maven.plugin.source;
  */
 
 import org.apache.maven.model.Resource;
+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 java.util.Collections;
@@ -30,18 +33,16 @@ import java.util.List;
  * as the test-jar goal but does not fork the build, and is suitable for attaching
  * to the build lifecycle.
  *
- * @goal test-jar-no-fork
- * @phase package
- * @threadSafe
  * @since 2.1
  */
+@Mojo( name = "test-jar-no-fork", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true )
 public class TestSourceJarNoForkMojo
     extends AbstractSourceJarMojo
 {
     /**
-     * @parameter expression="${maven.source.test.classifier}" default-value="test-sources"
      * @since 2.2
      */
+    @Parameter( property = "maven.source.test.classifier", defaultValue = "test-sources" )
     protected String classifier;
 
     /**