You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "C Divilly (JIRA)" <ji...@codehaus.org> on 2010/03/16 16:28:22 UTC

[jira] Commented: (MCOMPILER-97) META-INF/services/javax.annotation.processing.Processor copied before compilation and causes error

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

C Divilly commented on MCOMPILER-97:
------------------------------------

I used a variation of the above workaround, in my case I needed the outputs from the annotation processing to be packaged in the final jar not just generated for the testing phase. I added the following to my pom:

{noformat} 
<plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-compiler-plugin</artifactId>
 <version>2.1</version>
 <configuration>
  <source>1.6</source>
  <target>1.6</target>
 </configuration>
 <executions>
  <execution>
   <id>default-compile</id>
   <configuration>
    <compilerArgument>-proc:none</compilerArgument>
    <includes>
     <include>path/to/annotation/processor/**</include>
     <include>path/to/annotation/processor/dependencies/**</include>
    </includes>
   </configuration>
  </execution>
  <execution>
   <id>compile-everything-else</id>
   <phase>compile</phase>
   <goals>
    <goal>compile</goal>
   </goals>
  </execution>
 </executions>
</plugin>
{noformat} 

more detail on this approach [here|http://cdivilly.wordpress.com/2010/03/16/maven-and-jsr-269-annotation-processors/]

> META-INF/services/javax.annotation.processing.Processor copied before compilation and causes error
> --------------------------------------------------------------------------------------------------
>
>                 Key: MCOMPILER-97
>                 URL: http://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
>
>
> 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.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira