[ 
https://jira.codehaus.org/browse/MCOMPILER-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=272598#comment-272598
 ] 

Kohsuke Kawaguchi commented on MCOMPILER-97:
--------------------------------------------

My workaround is to define a separate Maven module (D) and defines a dummy 
do-nothing processor of the same fully-qualifled class name. This D module is 
then added as an optional dependency to my real project (R), so that D won't 
pollute other projects depending on R.

This has the added benefit of making IDEs happy, but the downside is that the 
test code won't be subject to the annotation processing (which is OK in my 
case, but may not be OK for others.)

> META-INF/services/javax.annotation.processing.Processor copied before 
> compilation and causes error
> --------------------------------------------------------------------------------------------------
>
>                 Key: MCOMPILER-97
>                 URL: https://jira.codehaus.org/browse/MCOMPILER-97
>             Project: Maven 2.x Compiler Plugin
>          Issue Type: Bug
>    Affects Versions: 2.0.2
>         Environment: Ubuntu 8.10, JDK 6.
>            Reporter: Jesse Glick
>         Attachments: maven-6647998-test.zip, MCOMPILER-97-workaround.zip
>
>
> It is tricky to compile a Maven module which defines a (269-compliant) 
> annotation processor. If you write the code for the processor in 
> src/main/java and register it in src/main/resources, 
> META-INF/services/javax.annotation.processing.Processor is copied to 
> target/classes first, and then javac is run. But javac is given 
> target/classes in -classpath, so it tries to load the processor, which of 
> course has not been compiled yet - a chicken-and-egg problem.
> The most straightforward workaround is to specify 
> <compilerArgument>-proc:none</compilerArgument> in your POM. This will only 
> work, however, if the module does not use any annotation processors defined 
> in dependencies. If it does, there may be some other trick involving 
> -processorpath and Maven variable substitution to insert the dependency 
> classpath.
> Switching the order of resources:resources and compiler:compile would help - 
> at least a clean build would work - though it could still cause problems in 
> incremental builds. Better would be for the compiler plugin to pass 
> -processorpath based on the dependency classpath (i.e. -classpath minus 
> target/classes) when using -source 1.6 or higher.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to