Setting the generated source directory for annotation processors in Maven

The plugin was using the harcoded Windows classpath separator to build the classpath, so it was failing on my Linux machine.

Submitted patches:

  • system dependent path separator character
  • Allow the default processor discovery mechanism to run

Not exactly an answer to your question, but of interest:

https://issues.apache.org/jira/browse/MCOMPILER-75

I'm afraid there are a number of issues using JSR 269 in Maven, at least with the default compiler plugin.


I may be missing something but shouldn't you:

  1. Generate sources in target/generated-sources/annotation-processing during the generate-sources phase? The apt-maven-plugin or the maven-annotation-plugin could help.

  2. Include generated sources when compiling sources into target/classes using <includes> in the maven-compiler-plugin or the maven-build-helper-plugin?

EDIT: Where is xxx.annotation.EnforceJavaBeansConventionsProcessor located? Don't you need to add dependencies to the configuration of the maven-annotation-plugin as documented on the Usage page?

<plugin>
  <groupId>org.bsc.maven</groupId>
  <artifactId>maven-processor-plugin</artifactId>
  <version>1.0-SNAPSHOT</version>
  <executions>
    <execution>
      <id>process</id>
      <goals>
        <goal>process</goal>
      </goals>
      <phase>generate-sources</phase>
      <configuration>
        <outputDirectory>src/main/generated</outputDirectory><!-- PROCESSOR OUT DIR --> 
        <processors><!-- LIST OF PROCESSOR CLASS(S) -->
          <processor>org.bsc.apt.BeanInfoAnnotationProcessor</processor>
        </processors>
      </configuration> 
    </execution>
  </executions>
  <dependencies/><!-- ADD DEPENDENCIES HERE IF REQUIRED -->
</plugin>

PS: I wouldn't use src/main/generated as output directory but rather a subdirectory of target/generated-sources.