diff --git a/pom.xml b/pom.xml index a3c5717..64dcc59 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.bsc.maven maven-processor-plugin maven-plugin - 2.0.9-SNAPSHOT + 2.1.0-SNAPSHOT maven-processor-plugin - ${project.version} A maven plugin to process annotation for jdk6 at compile time @@ -11,6 +11,7 @@ This plugin helps to use from maven the new annotation processing provided by JD This plugin could be considered the 'alter ego' of maven apt plugin http://mojo.codehaus.org/apt-maven-plugin/ http://code.google.com/p/maven-annotation-plugin/ + @@ -21,6 +22,7 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo. + ${release.repo.id} @@ -104,13 +106,20 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo. - + + + org.apache.maven.plugin-tools + maven-plugin-annotations + 3.1 + + + + org.codehaus.plexus + plexus-utils + 3.0.1 + + + junit junit @@ -119,31 +128,6 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo. - @@ -161,21 +145,27 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo. - maven-plugin-plugin - 2.6 - - - - - - + org.apache.maven.plugins + maven-plugin-plugin + 3.1 + + true + + + + mojo-descriptor + + descriptor + + + + + help-goal + + helpmojo + + + diff --git a/src/main/java/org/bsc/maven/plugin/processor/AbstractAnnotationProcessorMojo.java b/src/main/java/org/bsc/maven/plugin/processor/AbstractAnnotationProcessorMojo.java index bfa10ca..67c5ece 100644 --- a/src/main/java/org/bsc/maven/plugin/processor/AbstractAnnotationProcessorMojo.java +++ b/src/main/java/org/bsc/maven/plugin/processor/AbstractAnnotationProcessorMojo.java @@ -33,6 +33,8 @@ import org.apache.maven.artifact.Artifact; 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.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.StringUtils; @@ -42,111 +44,108 @@ * * @author bsorrentino * - * @threadSafe */ public abstract class AbstractAnnotationProcessorMojo extends AbstractMojo { /** - * @parameter expression = "${project}" - * @readonly - * @required + * */ //@MojoParameter(expression = "${project}", readonly = true, required = true) + @Component protected MavenProject project; /** - * @parameter expression="${plugin.artifacts}" - * @readonly + * */ //@MojoParameter(expression="${plugin.artifacts}", readonly = true ) + @Component private java.util.List pluginArtifacts; /** * Specify the directory where to place generated source files (same behaviour of -s option) - * @parameter * */ //@MojoParameter(required = false, description = "Specify the directory where to place generated source files (same behaviour of -s option)") + @Parameter private File outputDirectory; /** * Annotation Processor FQN (Full Qualified Name) - when processors are not specified, the default discovery mechanism will be used - * @parameter * */ //@MojoParameter(required = false, description = "Annotation Processor FQN (Full Qualified Name) - when processors are not specified, the default discovery mechanism will be used") + @Parameter private String[] processors; /** * Additional compiler arguments - * @parameter * */ //@MojoParameter(required = false, description = "Additional compiler arguments") + @Parameter private String compilerArguments; /** * Additional processor options (see javax.annotation.processing.ProcessingEnvironment#getOptions() - * @parameter alias="options" * */ + @Parameter( alias = "options" ) private java.util.Map optionMap; /** * Controls whether or not the output directory is added to compilation - * @parameter */ //@MojoParameter(required = false, description = "Controls whether or not the output directory is added to compilation") + @Parameter private Boolean addOutputDirectoryToCompilationSources; /** * Indicates whether the build will continue even if there are compilation errors; defaults to true. - * @parameter default-value="true" expression = "${annotation.failOnError}" - * @required */ //@MojoParameter(required = true, defaultValue = "true", expression = "${annotation.failOnError}", description = "Indicates whether the build will continue even if there are compilation errors; defaults to true.") + @Parameter( defaultValue="true", required=true, property="annotation.failOnError" ) private Boolean failOnError = true; /** * Indicates whether the compiler output should be visible, defaults to true. * - * @parameter expression = "${annotation.outputDiagnostics}" default-value="true" - * @required */ //@MojoParameter(required = true, defaultValue = "true", expression = "${annotation.outputDiagnostics}", description = "Indicates whether the compiler output should be visible, defaults to true.") + @Parameter( defaultValue="true", required=true, property="annotation.outputDiagnostics" ) private boolean outputDiagnostics = true; /** * System properties set before processor invocation. - * @parameter * */ //@MojoParameter(required = false, description = "System properties set before processor invocation.") + @Parameter private java.util.Map systemProperties; /** * includes pattern - * @parameter */ //@MojoParameter( description="includes pattern") + @Parameter private String[] includes; /** * excludes pattern - * @parameter */ //@MojoParameter( description="excludes pattern") + @Parameter private String[] excludes; - - private static final Lock syncExecutionLock = new ReentrantLock(); - /** * additional source directories for the annotation processors. - * @parameter */ + @Parameter private File[] additionalSourceDirectories; + + + private static final Lock syncExecutionLock = new ReentrantLock(); + public File[] getAdditionalSourceDirectories() { if( additionalSourceDirectories == null ) { diff --git a/src/main/java/org/bsc/maven/plugin/processor/MainAnnotationProcessorMojo.java b/src/main/java/org/bsc/maven/plugin/processor/MainAnnotationProcessorMojo.java index 2860697..a22b512 100644 --- a/src/main/java/org/bsc/maven/plugin/processor/MainAnnotationProcessorMojo.java +++ b/src/main/java/org/bsc/maven/plugin/processor/MainAnnotationProcessorMojo.java @@ -22,54 +22,51 @@ import java.util.List; 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.plugins.annotations.ResolutionScope; import org.apache.maven.project.MavenProject; /** * * @author bsorrentino * - * @goal process - * @requiresDependencyResolution compile - * @phase generate-sources */ -//@MojoGoal("process") -//@MojoRequiresDependencyResolution(value = "compile") -//@MojoPhase("generate-sources") +@Mojo(name="process",threadSafe=true,requiresDependencyResolution= ResolutionScope.COMPILE,defaultPhase= LifecyclePhase.GENERATE_SOURCES) public class MainAnnotationProcessorMojo extends AbstractAnnotationProcessorMojo { /** * project classpath * - * @parameter expression = "${project.compileClasspathElements}" - * @required - * @readonly */ @SuppressWarnings("rawtypes") //@MojoParameter(expression = "${project.compileClasspathElements}", required = true, readonly = true) + @Parameter( defaultValue="${project.compileClasspathElements}", required=true, readonly=true) private List classpathElements; /** * project sourceDirectory * - * @parameter expression = "${project.build.sourceDirectory}" - * @required */ //@MojoParameter(expression = "${project.build.sourceDirectory}", required = true) + @Parameter( defaultValue="${project.build.sourceDirectory}", required = true) private File sourceDirectory; /** - * @parameter expression = "${project.build.directory}/generated-sources/apt" - * @required + * default output directory + * */ //@MojoParameter(expression = "${project.build.directory}/generated-sources/apt", required = true) + @Parameter( defaultValue="${project.build.directory}/generated-sources/apt", required = true) private File defaultOutputDirectory; /** * Set the destination directory for class files (same behaviour of -d option) * - * @parameter expression="${project.build.outputDirectory}" */ //@MojoParameter(required = false, expression="${project.build.outputDirectory}", description = "Set the destination directory for class files (same behaviour of -d option)") + @Parameter( defaultValue="${project.build.outputDirectory}") private File outputClassDirectory; @Override diff --git a/src/main/java/org/bsc/maven/plugin/processor/TestAnnotationProcessorMojo.java b/src/main/java/org/bsc/maven/plugin/processor/TestAnnotationProcessorMojo.java index 4302cbc..afe8bf5 100644 --- a/src/main/java/org/bsc/maven/plugin/processor/TestAnnotationProcessorMojo.java +++ b/src/main/java/org/bsc/maven/plugin/processor/TestAnnotationProcessorMojo.java @@ -22,55 +22,51 @@ import java.util.List; 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.plugins.annotations.ResolutionScope; import org.apache.maven.project.MavenProject; /** * * @author bsorrentino * - * @goal process-test - * @requiresDependencyResolution test - * @phase generate-test-sources */ -//@MojoGoal("process-test") -//@MojoRequiresDependencyResolution(value = "test") -//@MojoPhase("generate-test-sources") +@Mojo(name="process-test",threadSafe=true,requiresDependencyResolution= ResolutionScope.TEST,defaultPhase= LifecyclePhase.GENERATE_TEST_SOURCES) public class TestAnnotationProcessorMojo extends AbstractAnnotationProcessorMojo { /** * project classpath * - * @parameter expression = "${project.testClasspathElements}" - * @required - * @readonly */ @SuppressWarnings("rawtypes") //@MojoParameter(expression = "${project.testClasspathElements}", required = true, readonly = true) + @Parameter( defaultValue="${project.testClasspathElements}", required=true, readonly=true) private List classpathElements; /** * - * @parameter expression = "${project.build.testSourceDirectory}" - * @required */ //@MojoParameter(expression = "${project.build.testSourceDirectory}", required = true) + @Parameter( defaultValue="${project.build.testSourceDirectory}", required = true) private File sourceDirectory; /** - * @parameter expression = "${project.build.directory}/generated-sources/apt-test" - * @required + * */ //@MojoParameter(expression = "${project.build.directory}/generated-sources/apt-test", required = true) + @Parameter( defaultValue="${project.build.directory}/generated-sources/apt-test", required = true) private File defaultOutputDirectory; /** * Set the destination directory for class files (same behaviour of -d option) * - * @parameter expression="${project.build.testOutputDirectory}" */ //@MojoParameter(required = false, expression="${project.build.testOutputDirectory}", description = "Set the destination directory for class files (same behaviour of -d option)") + @Parameter( defaultValue="${project.build.testOutputDirectory}") private File outputClassDirectory; @Override