Author: olamy Date: Mon Jun 18 21:02:06 2012 New Revision: 1351485 URL: http://svn.apache.org/viewvc?rev=1351485&view=rev Log: [MCOMPILER-173] use new maven plugin annotations.
svn merge -r 1337378:1351482 https://svn.apache.org/repos/asf/maven/plugins/branches/maven-compiler-plugin-annotations Modified: maven/plugins/trunk/maven-compiler-plugin/ (props changed) maven/plugins/trunk/maven-compiler-plugin/pom.xml maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/AbstractCompilerMojo.java maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java Propchange: maven/plugins/trunk/maven-compiler-plugin/ ------------------------------------------------------------------------------ --- svn:mergeinfo (added) +++ svn:mergeinfo Mon Jun 18 21:02:06 2012 @@ -0,0 +1 @@ +/maven/plugins/branches/maven-compiler-plugin-annotations:1337379-1351482 Modified: maven/plugins/trunk/maven-compiler-plugin/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/pom.xml?rev=1351485&r1=1351484&r2=1351485&view=diff ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/pom.xml (original) +++ maven/plugins/trunk/maven-compiler-plugin/pom.xml Mon Jun 18 21:02:06 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</version> + <scope>compile</scope> + </dependency> <!-- Maven --> <dependency> <groupId>org.apache.maven</groupId> @@ -172,6 +178,46 @@ under the License. </dependency> </dependencies> + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-plugin-plugin</artifactId> + <version>3.0</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>3.0</version> + </plugin> + </plugins> + </reporting> + <profiles> <profile> <id>run-its</id> Modified: maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/AbstractCompilerMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/AbstractCompilerMojo.java?rev=1351485&r1=1351484&r2=1351485&view=diff ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/AbstractCompilerMojo.java (original) +++ maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/AbstractCompilerMojo.java Mon Jun 18 21:02:06 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( property = "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( property = "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( property = "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( property = "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( property = "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( property = "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( property = "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( property = "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( property = "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( property = "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( property = "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( property = "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( property = "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( property = "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( property = "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( property = "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 * </compilerArguments> * </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( property = "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 */ + @Component 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}", property = "maven.compiler.compilerReuseStrategy" ) private String compilerReuseStrategy = "reuseCreated"; /** - * @parameter default-value="${false}" expression="${maven.compiler.skipMultiThreadWarning}" * @since 2.5 */ + @Parameter( defaultValue = "false", property = "maven.compiler.skipMultiThreadWarning" ) private boolean skipMultiThreadWarning; protected abstract SourceInclusionScanner getSourceInclusionScanner( int staleMillis ); Modified: maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java?rev=1351485&r1=1351484&r2=1351485&view=diff ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java (original) +++ maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/CompilerMojo.java Mon Jun 18 21:02:06 2012 @@ -20,6 +20,9 @@ package org.apache.maven.plugin; */ import org.apache.maven.artifact.Artifact; +import org.apache.maven.plugins.annotations.ResolutionScope; +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 +40,48 @@ import java.util.Set; * @author <a href="mailto:[email protected]">Jason van Zyl </a> * @version $Id$ * @since 2.0 - * @goal compile - * @phase compile - * @threadSafe - * @requiresDependencyResolution compile */ [email protected]( name = "compile", defaultPhase = LifecyclePhase.COMPILE, threadSafe = true, + requiresDependencyResolution = ResolutionScope.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 +89,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 +165,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/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java?rev=1351485&r1=1351484&r2=1351485&view=diff ============================================================================== --- maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java (original) +++ maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/TestCompilerMojo.java Mon Jun 18 21:02:06 2012 @@ -19,6 +19,9 @@ package org.apache.maven.plugin; * under the License. */ +import org.apache.maven.plugins.annotations.ResolutionScope; +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 +39,63 @@ import java.util.Set; * @author <a href="mailto:[email protected]">Jason van Zyl</a> * @version $Id$ * @since 2.0 - * @goal testCompile - * @phase test-compile - * @threadSafe - * @requiresDependencyResolution test */ [email protected]( name = "testCompile", defaultPhase = LifecyclePhase.TEST_COMPILE, + threadSafe = true, requiresDependencyResolution = ResolutionScope.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( property = "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( property = "maven.compiler.testSource" ) private String testSource; /** * The -target argument for the test Java compiler. * - * @parameter expression="${maven.compiler.testTarget}" * @since 2.1 */ + @Parameter( property = "maven.compiler.testTarget" ) private String testTarget; @@ -119,9 +108,9 @@ public class TestCompilerMojo * varies based on the compiler version. * </p> * - * @parameter * @since 2.1 */ + @Parameter private Map<String, String> testCompilerArguments; /** @@ -133,9 +122,9 @@ public class TestCompilerMojo * varies based on the compiler version. * </p> * - * @parameter * @since 2.1 */ + @Parameter private String testCompilerArgument; /** @@ -143,9 +132,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 +210,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; }
