Hi team, That's a long time I didn't play with annotations processors and there is something I don't understand. Maybe I get it wrong with annotations processors and/or with Maven What I want to accomplish is very similar to this post on stackoverflow: https://cloudbees.atlassian.net/wiki/spaces/CE/blog/1294434773/Info%2BA%2Bnew%2Bhome%2Bfor%2BFastThread To summarise we have an annotation processor that we want to run the module sources to generate automatically some tests. The problem is in the maven configuration. The proposed solution should work from my POV:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <executions> <execution> <!-- Generates test classes into ${project.build.directory}/generated-test-sources/test-annotations WITHOUT compiling them --> <id>generate-test-classes</id> <goals> <goal>compile</goal> </goals> <configuration> <annotationProcessors> <annotationProcessor>org.my.UnitTestGenerationProcessor</annotationProcessor> </annotationProcessors> <generatedSourcesDirectory>${project.build.directory}/generated-test-sources/test-annotations</generatedSourcesDirectory> <!-- generated class depends on test-scope libs, so don't compile now: proc:only DISABLES compilation of generated classes--> <proc>only</proc> </configuration> </execution> </executions> </plugin> <plugin> <!-- adds source-dir during generate-test-sources:add-test-source so that the path to our generated class is now known to the compiler during test-compile:testCompile --> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <executions> <execution> <id>add-test-source</id> <phase>generate-test-sources</phase> <goals> <goal>add-test-source</goal> </goals> <configuration> <sources> <source>${project.build.directory}/generated-test-sources/test-annotations</source> </sources> </configuration> </execution> </executions> </plugin> </plugins> </build> But it doesn't work and the call of generate-test-classes tries to compile the generated test sources (even if proc=only) and it fails because the Test classes are missing the test dependencies. Any idea of what we could do wrong ? -- ----- Arnaud Héritier http://aheritier.net Mail/GTalk: aheritier AT gmail DOT com Twitter/Skype : aheritier