What\'s the best way to setup the eclipse project compiler configuration for Java 6 annotation processors?
My solution is to setup the org.eclipse.jdt.apt.core.pre
Update: You could try using the apt-maven-plugin. It currently provides three goals:
You can configure the goals to run as part of your build as follows:
<build>
...
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<goals>
<goal>process</goal>
<goal>test-process</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
...
</build>
By default the output directory is set to ${project.build.directory}/generated-sources/apt
,
There is an open Jira against the compiler plugin to add APT support for Java 6, you can go and vote for it if this is something you want to to see in future versions.
There is a simpler solution in Eclipse Juno (I'm not sure about previous versions). In Preferences / Maven / Annotation Processing there are three modes for annotation processing. It is disabled by default, but I've tested both other options and worked like a charm for me. This way, you don't need to configure APT processing for every project or modify its pom.xml.
I am using http://code.google.com/p/maven-annotation-plugin/ wich is simpler to configure. You can use it in two ways:
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<compilerArguments>-encoding ${project.build.sourceEncoding}</compilerArguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<executions>
<execution>
<id>process-test</id>
<goals>
<goal>process-test</goal>
</goals>
<phase>generate-test-sources</phase>
<configuration>
<compilerArguments>-encoding ${project.build.sourceEncoding}</compilerArguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>${project.build.sourceEncoding}</encoding>
<!-- Disable annotation processors during normal compilation -->
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>