You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "John R. Fallows" <jo...@gmail.com> on 2007/06/18 21:49:23 UTC

[m2] Java 6 Annotation Processors fail to compile due to target/classes on Project.compileClasspath

Gang,

The Java 6 compiler leverages
META-INF/services/javax.annotation.processor.Processor to register
annotation processors, such that they would be executed transparently during
Java compilation.  These processor services are discovered using the
processorPath and compilation classPath arguments for javac in Java 6.

The maven-compiler-plugin sets the Java 6 compiler classpath to include
target/classes for the current project.  When the current project defines a
new annotation processor that is also registered via
META-INF/services/javax.annotation.processor.Processor, then the
META-INF/services/... resources are copied into target/classes before the
Java 6 compiler executes.  When the Java 6 compiler executes, it attempts to
discover all registered annotation processor services.  Naturally, it fails
to discover the new annotation processor class developed in the current
project because compilation has not yet completed for the current project.

One possible workaround would be to completely disable annotation processing
for the current project (-proc:none), to prevent automated discovery of
META-INF/services/... but that is not a viable workaround if annotation
processors from dependent projects are required to be executed during the
compilation of the current project.

I have checked out the maven-2.0.8-SNAPSHOT branch and removed the following
line

        list.add( getBuild().getOutputDirectory() );

from org/apache/maven/project/MavenProject.java,
getCompileClasspathElements().

With this change in place, the annotation processor project now compiles
successfully.

How do you recommend we proceed from here to fully support Java 6 annotation
processor projects in Maven2?

Kind Regards,
John Fallows.