Skip to content

Commit

Permalink
Issue 44
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino committed Oct 12, 2012
1 parent 5e204bb commit 57a0baf
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 98 deletions.
86 changes: 38 additions & 48 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>2.0.9-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
<name>maven-processor-plugin - ${project.version}</name>
<description>A maven plugin to process annotation for jdk6 at compile time

This plugin helps to use from maven the new annotation processing provided by JDK6 integrated in java compiler

This plugin could be considered the 'alter ego' of maven apt plugin http://mojo.codehaus.org/apt-maven-plugin/ </description>
<url>http://code.google.com/p/maven-annotation-plugin/</url>

<reporting>
<plugins>
<plugin>
Expand All @@ -21,6 +22,7 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo.
</plugins>
</reporting>


<distributionManagement>
<repository>
<id>${release.repo.id}</id>
Expand Down Expand Up @@ -104,13 +106,20 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo.



<!--
<dependency>
<groupId>org.jfrog.maven.annomojo</groupId>
<artifactId>maven-plugin-tools-anno</artifactId>
<version>${maven.anno.version}</version>
</dependency>
-->
<!-- dependencies to annotations -->
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.1</version>
</dependency>
<!-- generated help mojo has a dependency to plexus-utils -->
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.0.1</version>
</dependency>


<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -119,31 +128,6 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo.
</dependency>
</dependencies>

<!--
<repositories>
<repository>
<id>jfrog</id>
<name>jfrog repository</name>
<layout>default</layout>
<url>http://repo.jfrog.org/artifactory/plugins-releases-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>jfrog</id>
<name>jfrog repository</name>
<layout>default</layout>
<url>http://repo.jfrog.org/artifactory/plugins-releases-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
-->

<build>

Expand All @@ -161,21 +145,27 @@ This plugin could be considered the 'alter ego' of maven apt plugin http://mojo.
</plugin>

<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<version>2.6</version>

<dependencies>
<!--
<dependency>
<groupId>org.jfrog.maven.annomojo</groupId>
<artifactId>maven-plugin-tools-anno</artifactId>
<version>${maven.anno.version}</version>
<scope>runtime</scope>
</dependency>
-->
</dependencies>


<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.1</version>
<configuration>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
<executions>
<execution>
<id>mojo-descriptor</id>
<goals>
<goal>descriptor</goal>
</goals>
</execution>
<!-- if you want to generate help goal -->
<execution>
<id>help-goal</id>
<goals>
<goal>helpmojo</goal>
</goals>
</execution>
</executions>
</plugin>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Artifact> 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<String,Object> 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<String,String> 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 ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 57a0baf

Please sign in to comment.