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/05/12 00:48:22 UTC

svn commit: r1337405 - in /maven/plugins/branches/maven-compiler-plugin-annotations: ./ src/main/java/org/apache/maven/plugin/

Author: olamy
Date: Fri May 11 22:48:22 2012
New Revision: 1337405

URL: http://svn.apache.org/viewvc?rev=1337405&view=rev
Log:
use annotations

Modified:
    maven/plugins/branches/maven-compiler-plugin-annotations/pom.xml
    maven/plugins/branches/maven-compiler-plugin-annotations/src/main/java/org/apache/maven/plugin/AbstractCompilerMojo.java
    maven/plugins/branches/maven-compiler-plugin-annotations/src/main/java/org/apache/maven/plugin/CompilerMojo.java
    maven/plugins/branches/maven-compiler-plugin-annotations/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java

Modified: maven/plugins/branches/maven-compiler-plugin-annotations/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-compiler-plugin-annotations/pom.xml?rev=1337405&r1=1337404&r2=1337405&view=diff
==============================================================================
--- maven/plugins/branches/maven-compiler-plugin-annotations/pom.xml (original)
+++ maven/plugins/branches/maven-compiler-plugin-annotations/pom.xml Fri May 11 22:48:22 2012
@@ -57,6 +57,12 @@ under the License.
   </properties>
 
   <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.plugin-tools</groupId>
+      <artifactId>maven-plugin-annotations</artifactId>
+      <version>3.0-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>
     <!-- Maven -->
     <dependency>
       <groupId>org.apache.maven</groupId>
@@ -166,6 +172,36 @@ under the License.
     </dependency>
   </dependencies>
 
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-plugin-plugin</artifactId>
+          <version>3.0-SNAPSHOT</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>
+
   <profiles>
     <profile>
       <id>run-its</id>

Modified: maven/plugins/branches/maven-compiler-plugin-annotations/src/main/java/org/apache/maven/plugin/AbstractCompilerMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-compiler-plugin-annotations/src/main/java/org/apache/maven/plugin/AbstractCompilerMojo.java?rev=1337405&r1=1337404&r2=1337405&view=diff
==============================================================================
--- maven/plugins/branches/maven-compiler-plugin-annotations/src/main/java/org/apache/maven/plugin/AbstractCompilerMojo.java (original)
+++ maven/plugins/branches/maven-compiler-plugin-annotations/src/main/java/org/apache/maven/plugin/AbstractCompilerMojo.java Fri May 11 22:48:22 2012
@@ -20,6 +20,8 @@ package org.apache.maven.plugin;
  */
 
 import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.toolchain.Toolchain;
 import org.apache.maven.toolchain.ToolchainManager;
 import org.codehaus.plexus.compiler.Compiler;
@@ -67,122 +69,110 @@ public abstract class AbstractCompilerMo
     /**
      * Indicates whether the build will continue even if there are compilation errors.
      *
-     * @parameter expression="${maven.compiler.failOnError}" default-value="true"
      * @since 2.0.2
      */
+    @Parameter( expression = "${maven.compiler.failOnError}", defaultValue = "true" )
     private boolean failOnError = true;
 
     /**
      * Set to <code>true</code> to include debugging information in the compiled class files.
-     *
-     * @parameter expression="${maven.compiler.debug}" default-value="true"
      */
+    @Parameter( expression = "${maven.compiler.debug}", defaultValue = "true" )
     private boolean debug = true;
 
     /**
      * Set to <code>true</code> to show messages about what the compiler is doing.
-     *
-     * @parameter expression="${maven.compiler.verbose}" default-value="false"
      */
+    @Parameter( expression = "${maven.compiler.verbose}", defaultValue = "false" )
     private boolean verbose;
 
     /**
      * Sets whether to show source locations where deprecated APIs are used.
-     *
-     * @parameter expression="${maven.compiler.showDeprecation}" default-value="false"
      */
+    @Parameter( expression = "${maven.compiler.showDeprecation}", defaultValue = "false" )
     private boolean showDeprecation;
 
     /**
      * Set to <code>true</code> to optimize the compiled code using the compiler's optimization methods.
-     *
-     * @parameter expression="${maven.compiler.optimize}" default-value="false"
      */
+    @Parameter( expression = "${maven.compiler.optimize}", defaultValue = "false" )
     private boolean optimize;
 
     /**
      * Set to <code>true</code> to show compilation warnings.
-     *
-     * @parameter expression="${maven.compiler.showWarnings}" default-value="false"
      */
+    @Parameter( expression = "${maven.compiler.showWarnings}", defaultValue = "false" )
     private boolean showWarnings;
 
     /**
      * The -source argument for the Java compiler.
-     *
-     * @parameter expression="${maven.compiler.source}" default-value="1.5"
      */
+    @Parameter( expression = "${maven.compiler.source}", defaultValue = "1.5" )
     protected String source;
 
     /**
      * The -target argument for the Java compiler.
-     *
-     * @parameter expression="${maven.compiler.target}" default-value="1.5"
      */
+    @Parameter( expression = "${maven.compiler.target}", defaultValue = "1.5" )
     protected String target;
 
     /**
      * The -encoding argument for the Java compiler.
      *
-     * @parameter expression="${encoding}" default-value="${project.build.sourceEncoding}"
      * @since 2.1
      */
+    @Parameter( expression = "${encoding}", defaultValue = "${project.build.sourceEncoding}" )
     private String encoding;
 
     /**
      * Sets the granularity in milliseconds of the last modification
      * date for testing whether a source needs recompilation.
-     *
-     * @parameter expression="${lastModGranularityMs}" default-value="0"
      */
+    @Parameter( expression = "${lastModGranularityMs}", defaultValue = "0" )
     private int staleMillis;
 
     /**
      * The compiler id of the compiler to use. See this
      * <a href="non-javac-compilers.html">guide</a> for more information.
-     *
-     * @parameter expression="${maven.compiler.compilerId}" default-value="javac"
      */
+    @Parameter( expression = "${maven.compiler.compilerId}", defaultValue = "javac" )
     private String compilerId;
 
     /**
      * Version of the compiler to use, ex. "1.3", "1.5", if {@link #fork} is set to <code>true</code>.
-     *
-     * @parameter expression="${maven.compiler.compilerVersion}"
      */
+    @Parameter( expression = "${maven.compiler.compilerVersion}" )
     private String compilerVersion;
 
     /**
      * Allows running the compiler in a separate process.
      * If <code>false</code> it uses the built in compiler, while if <code>true</code> it will use an executable.
-     *
-     * @parameter expression="${maven.compiler.fork}" default-value="false"
      */
+    @Parameter( expression = "${maven.compiler.fork}", defaultValue = "false" )
     private boolean fork;
 
     /**
      * Initial size, in megabytes, of the memory allocation pool, ex. "64", "64m"
      * if {@link #fork} is set to <code>true</code>.
      *
-     * @parameter expression="${maven.compiler.meminitial}"
      * @since 2.0.1
      */
+    @Parameter( expression = "${maven.compiler.meminitial}" )
     private String meminitial;
 
     /**
      * Sets the maximum size, in megabytes, of the memory allocation pool, ex. "128", "128m"
      * if {@link #fork} is set to <code>true</code>.
      *
-     * @parameter expression="${maven.compiler.maxmem}"
      * @since 2.0.1
      */
+    @Parameter( expression = "${maven.compiler.maxmem}" )
     private String maxmem;
 
     /**
      * Sets the executable of the compiler to use when {@link #fork} is <code>true</code>.
-     *
-     * @parameter expression="${maven.compiler.executable}"
      */
+    @Parameter( expression = "${maven.compiler.executable}" )
     private String executable;
 
     /**
@@ -196,9 +186,9 @@ public abstract class AbstractCompilerMo
      * <li><code>only</code> - only annotation processing is done, no compilation.</li>
      * </ul>
      *
-     * @parameter
      * @since 2.2
      */
+    @Parameter
     private String proc;
 
     /**
@@ -207,9 +197,9 @@ public abstract class AbstractCompilerMo
      * If not set, the default annotation processors discovery process applies.
      * </p>
      *
-     * @parameter
      * @since 2.2
      */
+    @Parameter
     private String[] annotationProcessors;
 
     /**
@@ -232,9 +222,9 @@ public abstract class AbstractCompilerMo
      * &lt;/compilerArguments&gt;
      * </pre>
      *
-     * @parameter
      * @since 2.0.1
      */
+    @Parameter
     protected Map<String, String> compilerArguments;
 
     /**
@@ -246,33 +236,34 @@ public abstract class AbstractCompilerMo
      * This is because the list of valid arguments passed to a Java compiler
      * varies based on the compiler version.
      * </p>
-     *
-     * @parameter
      */
+    @Parameter
     protected String compilerArgument;
 
     /**
      * Sets the name of the output file when compiling a set of
      * sources to a single file.
-     *
-     * @parameter expression="${project.build.finalName}"
+     * <p/>
+     * expression="${project.build.finalName}"
      */
+    @Parameter
     private String outputFileName;
 
     /**
-     * Keyword list to be appended to the <code>-g</code> command-line switch. Legal values are none or a 
+     * Keyword list to be appended to the <code>-g</code> command-line switch. Legal values are none or a
      * comma-separated list of the following keywords: <code>lines</code>, <code>vars</code>, and <code>source</code>.
      * If debug level is not specified, by default, nothing will be appended to <code>-g</code>.
      * If debug is not turned on, this attribute will be ignored.
      *
-     * @parameter expression="${maven.compiler.debuglevel}"
      * @since 2.1
      */
+    @Parameter( expression = "${maven.compiler.debuglevel}" )
     private String debuglevel;
 
     /**
-     * @component
+     *
      */
+    @Component
     private ToolchainManager toolchainManager;
 
     // ----------------------------------------------------------------------
@@ -281,57 +272,47 @@ public abstract class AbstractCompilerMo
 
     /**
      * The directory to run the compiler from if fork is true.
-     *
-     * @parameter default-value="${basedir}"
-     * @required
-     * @readonly
      */
+    @Parameter( defaultValue = "${basedir}", required = true, readonly = true )
     private File basedir;
 
     /**
      * The target directory of the compiler if fork is true.
-     *
-     * @parameter default-value="${project.build.directory}"
-     * @required
-     * @readonly
      */
+    @Parameter( defaultValue = "${project.build.directory}", required = true, readonly = true )
     private File buildDirectory;
 
     /**
      * Plexus compiler manager.
-     *
-     * @component
      */
+    @Component
     private CompilerManager compilerManager;
 
     /**
      * The current build session instance. This is used for toolchain manager API calls.
-     *
-     * @parameter default-value="${session}"
-     * @required
-     * @readonly
      */
+    @Parameter( defaultValue = "${session}", required = true, readonly = true )
     private MavenSession session;
 
     /**
      * Strategy to re use javacc class created:
      * <ul>
-     *   <li><code>reuseCreated</code> (default): will reuse already created but in case of multi-threaded builds,
-     *   each thread will have its own instance</li>
-     *   <li><code>reuseSame</code>: the same Javacc class will be used for each compilation even for multi-threaded build</li>
-     *   <li><code>alwaysNew</code>: a new Javacc class will be created for each compilation</li>
+     * <li><code>reuseCreated</code> (default): will reuse already created but in case of multi-threaded builds,
+     * each thread will have its own instance</li>
+     * <li><code>reuseSame</code>: the same Javacc class will be used for each compilation even for multi-threaded build</li>
+     * <li><code>alwaysNew</code>: a new Javacc class will be created for each compilation</li>
      * </ul>
      * Note this parameter value depends on the os/jdk you are using, but the default value should work on most of env.
      *
-     * @parameter default-value="${reuseCreated}" expression="${maven.compiler.compilerReuseStrategy}"
      * @since 2.5
      */
+    @Parameter( defaultValue = "${reuseCreated}", expression = "${maven.compiler.compilerReuseStrategy}" )
     private String compilerReuseStrategy = "reuseCreated";
 
     /**
-     * @parameter default-value="${false}" expression="${maven.compiler.skipMultiThreadWarning}"
      * @since 2.5
      */
+    @Parameter( defaultValue = "${false}", expression = "${maven.compiler.skipMultiThreadWarning}" )
     private boolean skipMultiThreadWarning;
 
     protected abstract SourceInclusionScanner getSourceInclusionScanner( int staleMillis );

Modified: maven/plugins/branches/maven-compiler-plugin-annotations/src/main/java/org/apache/maven/plugin/CompilerMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-compiler-plugin-annotations/src/main/java/org/apache/maven/plugin/CompilerMojo.java?rev=1337405&r1=1337404&r2=1337405&view=diff
==============================================================================
--- maven/plugins/branches/maven-compiler-plugin-annotations/src/main/java/org/apache/maven/plugin/CompilerMojo.java (original)
+++ maven/plugins/branches/maven-compiler-plugin-annotations/src/main/java/org/apache/maven/plugin/CompilerMojo.java Fri May 11 22:48:22 2012
@@ -20,6 +20,8 @@ package org.apache.maven.plugin;
  */
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Parameter;
 import org.codehaus.plexus.compiler.util.scan.SimpleSourceInclusionScanner;
 import org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner;
 import org.codehaus.plexus.compiler.util.scan.StaleSourceScanner;
@@ -37,63 +39,48 @@ import java.util.Set;
  * @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
  * @version $Id$
  * @since 2.0
- * @goal compile
- * @phase compile
- * @threadSafe
- * @requiresDependencyResolution compile
  */
+@org.apache.maven.plugins.annotations.Mojo( name = "compile", defaultPhase = LifecyclePhase.COMPILE, threadSafe = true,
+                                            requiresDependencyResolution = "compile" )
 public class CompilerMojo
     extends AbstractCompilerMojo
 {
     /**
      * The source directories containing the sources to be compiled.
-     *
-     * @parameter default-value="${project.compileSourceRoots}"
-     * @required
-     * @readonly
      */
+    @Parameter( defaultValue = "${project.compileSourceRoots}", readonly = true, required = true )
     private List<String> compileSourceRoots;
 
     /**
      * Project classpath.
-     *
-     * @parameter default-value="${project.compileClasspathElements}"
-     * @required
-     * @readonly
      */
+    @Parameter( defaultValue = "${project.compileClasspathElements}", readonly = true, required = true )
     private List<String> classpathElements;
 
     /**
      * The directory for compiled classes.
-     *
-     * @parameter default-value="${project.build.outputDirectory}"
-     * @required
-     * @readonly
      */
+    @Parameter( defaultValue = "${project.build.outputDirectory}", required = true, readonly = true )
     private File outputDirectory;
 
     /**
      * Project artifacts.
      *
-     * @parameter default-value="${project.artifact}"
-     * @required
-     * @readonly
      * @todo this is an export variable, really
      */
+    @Parameter( defaultValue = "${project.artifact}", readonly = true, required = true )
     private Artifact projectArtifact;
 
     /**
      * A list of inclusion filters for the compiler.
-     *
-     * @parameter
      */
+    @Parameter
     private Set<String> includes = new HashSet<String>();
 
     /**
      * A list of exclusion filters for the compiler.
-     *
-     * @parameter
      */
+    @Parameter
     private Set<String> excludes = new HashSet<String>();
 
     /**
@@ -101,9 +88,10 @@ public class CompilerMojo
      * Specify where to place generated source files created by annotation processing.
      * Only applies to JDK 1.6+
      * </p>
-     * @parameter default-value="${project.build.directory}/generated-sources/annotations"
+     *
      * @since 2.2
      */
+    @Parameter( defaultValue = "${project.build.directory}/generated-sources/annotations" )
     private File generatedSourcesDirectory;
 
 
@@ -176,22 +164,22 @@ public class CompilerMojo
 
     protected String getSource()
     {
-      return source;
+        return source;
     }
 
     protected String getTarget()
     {
-      return target;
+        return target;
     }
 
     protected String getCompilerArgument()
     {
-      return compilerArgument;
+        return compilerArgument;
     }
 
     protected Map<String, String> getCompilerArguments()
     {
-      return compilerArguments;
+        return compilerArguments;
     }
 
     protected File getGeneratedSourcesDirectory()

Modified: maven/plugins/branches/maven-compiler-plugin-annotations/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/maven-compiler-plugin-annotations/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java?rev=1337405&r1=1337404&r2=1337405&view=diff
==============================================================================
--- maven/plugins/branches/maven-compiler-plugin-annotations/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java (original)
+++ maven/plugins/branches/maven-compiler-plugin-annotations/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java Fri May 11 22:48:22 2012
@@ -19,6 +19,8 @@ package org.apache.maven.plugin;
  * under the License.
  */
 
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Parameter;
 import org.codehaus.plexus.compiler.util.scan.SimpleSourceInclusionScanner;
 import org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner;
 import org.codehaus.plexus.compiler.util.scan.StaleSourceScanner;
@@ -36,77 +38,63 @@ import java.util.Set;
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
  * @version $Id$
  * @since 2.0
- * @goal testCompile
- * @phase test-compile
- * @threadSafe
- * @requiresDependencyResolution test
  */
+@org.apache.maven.plugins.annotations.Mojo( name = "testCompile", defaultPhase = LifecyclePhase.TEST_COMPILE,
+                                            threadSafe = true, requiresDependencyResolution = "test" )
 public class TestCompilerMojo
     extends AbstractCompilerMojo
 {
     /**
      * Set this to 'true' to bypass compilation of test sources.
      * Its use is NOT RECOMMENDED, but quite convenient on occasion.
-     *
-     * @parameter expression="${maven.test.skip}"
      */
+    @Parameter( expression = "${maven.test.skip}" )
     private boolean skip;
 
     /**
      * The source directories containing the test-source to be compiled.
-     *
-     * @parameter default-value="${project.testCompileSourceRoots}"
-     * @required
-     * @readonly
      */
+    @Parameter( defaultValue = "${project.testCompileSourceRoots}", readonly = true, required = true )
     private List<String> compileSourceRoots;
 
     /**
      * Project test classpath.
-     *
-     * @parameter default-value="${project.testClasspathElements}"
-     * @required
-     * @readonly
      */
+    @Parameter( defaultValue = "${project.testClasspathElements}", required = true, readonly = true )
     private List<String> classpathElements;
 
     /**
      * The directory where compiled test classes go.
-     *
-     * @parameter default-value="${project.build.testOutputDirectory}"
-     * @required
-     * @readonly
      */
+    @Parameter( defaultValue = "${project.build.testOutputDirectory}", required = true, readonly = true )
     private File outputDirectory;
 
     /**
      * A list of inclusion filters for the compiler.
-     *
-     * @parameter
      */
+    @Parameter
     private Set<String> testIncludes = new HashSet<String>();
 
     /**
      * A list of exclusion filters for the compiler.
-     *
-     * @parameter
      */
+    @Parameter
     private Set<String> testExcludes = new HashSet<String>();
 
     /**
      * The -source argument for the test Java compiler.
      *
-     * @parameter expression="${maven.compiler.testSource}"
      * @since 2.1
      */
+    @Parameter( expression = "${maven.compiler.testSource}" )
     private String testSource;
 
     /**
      * The -target argument for the test Java compiler.
      *
-     * @parameter expression="${maven.compiler.testTarget}"
      * @since 2.1
      */
+    @Parameter( expression = "${maven.compiler.testTarget}" )
     private String testTarget;
 
 
@@ -119,9 +107,9 @@ public class TestCompilerMojo
      * varies based on the compiler version.
      * </p>
      *
-     * @parameter
      * @since 2.1
      */
+    @Parameter
     private Map<String, String> testCompilerArguments;
 
     /**
@@ -133,9 +121,9 @@ public class TestCompilerMojo
      * varies based on the compiler version.
      * </p>
      *
-     * @parameter
      * @since 2.1
      */
+    @Parameter
     private String testCompilerArgument;
 
     /**
@@ -143,9 +131,10 @@ public class TestCompilerMojo
      * Specify where to place generated source files created by annotation processing.
      * Only applies to JDK 1.6+
      * </p>
-     * @parameter default-value="${project.build.directory}/generated-test-sources/test-annotations"
+     *
      * @since 2.2
      */
+    @Parameter( defaultValue = "${project.build.directory}/generated-test-sources/test-annotations" )
     private File generatedTestSourcesDirectory;
 
 
@@ -220,25 +209,25 @@ public class TestCompilerMojo
 
     protected String getSource()
     {
-      return testSource == null ? source : testSource;
+        return testSource == null ? source : testSource;
     }
 
     protected String getTarget()
     {
-      return testTarget == null ? target : testTarget;
+        return testTarget == null ? target : testTarget;
     }
 
     protected String getCompilerArgument()
     {
-      return testCompilerArgument == null ? compilerArgument : testCompilerArgument;
+        return testCompilerArgument == null ? compilerArgument : testCompilerArgument;
     }
 
     protected Map<String, String> getCompilerArguments()
     {
-      return testCompilerArguments == null ? compilerArguments : testCompilerArguments;
+        return testCompilerArguments == null ? compilerArguments : testCompilerArguments;
     }
 
-    protected File getGeneratedSourcesDirectory() 
+    protected File getGeneratedSourcesDirectory()
     {
         return generatedTestSourcesDirectory;
     }