Eclipse Annotation Processing with Maven

714 views
Skip to first unread message

Ben Tatham

unread,
Oct 1, 2014, 8:32:11 PM10/1/14
to dagger-...@googlegroups.com
I believe this has been discussed before, but I can't find it.  Has anyone figured out a good way to keep annotation processing enabled in Eclipse, with a Maven project, when you have generated code for both compile and test scopes? 

Specifically, if I have annotation processing enabled in eclipse, it puts all generated code into the same directory, while maven separates it between two separate directories: target/generated-sources and target/generated-test-sources.   Then, Eclipse sees both sets of files and says the class has already been generated.

I suppose one way to handle it is to disable the automatic m2e-apt configurator so the maven target directories don't get added to the eclipse project, and then manually enable it in eclipse with a completely separate directory.  

Has anyone else had this problem and found a good solution?

Thanks,
Ben

Christian Gruber

unread,
Oct 1, 2014, 11:44:43 PM10/1/14
to dagger-...@googlegroups.com
Its sort of rough. Eclipse doesn't maintain separate class paths for prod and test code. So unless you move your texts into a separate maven module (so m2e will make a separate eclipse project for it) you're kind of out of luck.

--
You received this message because you are subscribed to the Google Groups "Dagger Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dagger-discus...@googlegroups.com.
To post to this group, send email to dagger-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thomas Broyer

unread,
Oct 2, 2014, 4:35:21 AM10/2/14
to dagger-...@googlegroups.com
IIRC m2e-apt has an option to delegate the processing to Maven (but that requires using the processor-maven-plugin, with the maven-compiler-plugin configured with <proc>none</proc>).
I never tried it (and I seem to recall it was labeled as experimental) but maybe it could be a solution. 

Ben Tatham

unread,
Oct 2, 2014, 11:01:33 AM10/2/14
to dagger-...@googlegroups.com
Using the "Delegate processing to Maven" does work, except for the caveat that I cannot disable the "Optional compile warnings" on the added generated sources directories (or if I do, m2e turns it back on with every update of the project).  This is annoying as it clogs up the Eclipse warnings with lots of checkstyle and other stuff since the style is different than our corporate standards.

Until Eclipse has separation of prod/test annotation processing output directories, we'll have to live with the pain.  I'm not we need full separation of classpaths to solve the problem...just annotation processing output directories based on source directories.  Given that the source directories can set class output directories separately, it's a shame they don't support the same for annotations. :(

-Ben

Ben Tatham

unread,
Oct 2, 2014, 11:07:14 AM10/2/14
to dagger-...@googlegroups.com
There is already an eclipse bug for this, but perhaps my assumptions about what is possible in eclipse are incorrect.

Ben Tatham

unread,
Oct 2, 2014, 5:35:47 PM10/2/14
to dagger-...@googlegroups.com
A heads up to future trollers of this list: I've found that, for reasons I cannot explain quite yet, it seems that the Qualifiers are left off of bindings (at least SET bindings) when using the m2e-apt delegation to the maven-processor-plugin.  In other words, the SET or SET_VALUES bindings that have qualifiers do not show up in the resulting sets, causing very annoying, hard to track down side-effects of not getting all your injected values into the resulting sets.
Reply all
Reply to author
Forward
0 new messages