Java – generated code not considered during Maven compilation
I have a maven project that generates a new class from the annotation processor during compilation The class was successfully generated in / target / generated sources / annotations /, but was not compiled to Jar Why?
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>${project.build.source}</source> <target>${project.build.target}</target> <encoding>${project.build.sourceEncoding}</encoding> <compilerArgument>-Xlint</compilerArgument> <annotationProcessors> <annotationProcessor>net.preprocessing.MyAnnotationProcessor</annotationProcessor> </annotationProcessors> </configuration> </plugin>
edit
This seems to be a well-known bug If someone has an operable solution, welcome
Edit 2
I had some tests yesterday, but the solutions suggested in the fault list didn't work I provided a test case If anyone knows how to solve this problem, welcome Remember, I'm new to annotation processing, so there may be something I don't know
Solution
I recommend using Maven processor plugin instead of the 'annotation processor' parameter passed to the Maven compiler
From what I've read, compiler arguments seems to have some problems, which will be solved when you use Maven processor plugin
Here you can find information about Maven processor plugin: http://maven-annotation-plugin.googlecode.com/svn/docs/usage.html More information about
The following is an example of how the processor plug-in replaces compilerarguments (this example uses hibernate metamodel generator, but this looks the same for all types of annotation processors...): http://relation.to/Bloggers/HibernateStaticMetamodelGeneratorAnnotationProcessor