maven-compiler-plugin does not do annotation processing when fork=true is specified? -



maven-compiler-plugin does not do annotation processing when fork=true is specified? -

i'm using maven-compiler-plugin in maven project perform annotation processing on code. working until added <fork>true</fork> configuration option.

the pom.xml file has following:

class="lang-xml prettyprint-override"><plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-compiler-plugin</artifactid> <version>2.5.1</version> <dependencies> <!-- add together dependency on annotation processor --> <dependency> <groupid>x.y.z</groupid> <artifactid>my-processor</artifactid> <version>1.0</version> </dependency> </dependencies> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin>

the my-processor-1.0.jar file contains meta-inf/services/javax.annotation.processing.processor file can discovered javac compiler @ runtime.

when run mvn clean compile configuration, see annotation processor runs , generated code set target\generated-sources\annotations directory, expected.

but if add together <fork>true</fork> alternative plugin configuration, observe annotation processor not run , no code nowadays in target\generated-sources\annotations directory.

i tried maven-compiler-plugin version 2.5.1, 3.0 , 3.1 (with 3.x versions had add together <forcejavacompileruser>true</forcejavacompileruser> alternative configuration annotation processor jar discovered).

i tried specifying annotation processor explicitly:

class="lang-xml prettyprint-override"><configuration> ... <annotationprocessors> <annotationprocessor>x.y.z.myprocessor</annotationprocessor> </annotationprocessors> ... </configuration>

again, version 2.5.1, 3.0, , 3.1, annotation processor invoked if configuration alternative did not specify forking. when <fork>true</fork> alternative specified, annotation processor not run.

i added x.y.z:my_processor dependency outside of maven-compiler-plugin dependency, create sure annotation processor dependency loaded.

should annotation processing still work when maven-compiler-plugin configured <fork>true</fork>? or configuring plugin incorrectly?

note not want split compilation separate executions (e.g. 1 execution compile without annotation processing, using <fork>true</fork>, , execution annotation processing, using <fork>false</fork>, since sec execution recompiles entire source again, bad when dealing thousands of source files, unless there way around this).

i using jdk 1.7.0_45.

edit #1

actually solution move processor dependency out of plugin's dependency , normal dependencies:

class="lang-xml prettyprint-override"><dependencies> <dependency> <groupid>x.y.z</groupid> <artifactid>my-processor</artifactid> </dependency> ... </dependencies> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-compiler-plugin</artifactid> <version>2.5.1</version> <configuration> <source>1.7</source> <target>1.7</target> <fork>true</fork> </configuration> </plugin> </plugin>

i thought had tested might have been looking console output (that not appear when process forked) instead of looking existence of generated code.

actually solution move processor dependency out of plugin's dependency , normal dependencies. see edit #1 in original post.

although, weirdly, compilation error when dependency added vs when dependency not added. without dependency, see compiler warning using internal proprietary api. when annotation processor dependency added, warning treated error. can't see -werror alternative in compiler options treat warnings errors. when annotation processor dependency removed, compilation passes warning. scratching head on 1 ...

maven annotations javac maven-compiler-plugin

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -