Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Annotation processing fails with Dagger 1.2.2, Gradle 2.4, Eclipse 4.5.0 Mars

Dagger 1.2.2, Gradle 2.4, Eclipse 4.5.0 Mars on OSX 10.9.5.

Attempting to run a JUnit test fails within Eclipse: "Please ensure that code generation was run for this module."

This is a Gradle project in Eclipse with the versions shown above.

JUnit tests run successfully from the command line ("./gradlew clean test").

Project Properties:Java Compiler:Annotation Processing shows: all check boxes checked. Generated code goes to .apt_generated. No Processor Options are specified.

Project Properties:Java Compiler:Annotation Processing:Factory Path shows: dagger-compiler-1.2.2.jar is present and checked, javawriter-2.5.0 is present and checked, dagger-1.2.2.jar is present and checked.

org.eclipse.jst.ws.annotations.core is present but not checked (checking it and rebuilding doesn't seem to make any difference).

The "checked" jars are all being taken from my ~/.gradle/caches directory.

Nothing appears in the .apt_generated directory (I gather that generated class files are supposed to appear there; I've never seen any.)

Thoughts? [Edit: added missing word "line"]

like image 375
pdx_jjb_nr Avatar asked Oct 31 '22 21:10

pdx_jjb_nr


1 Answers

Another developer here knew the answer to this question:

Open the Properties of the project that uses Dagger (use the project context menu, not the main menu).

Go to Java Compiler: Annotation Processing.

Deselect the Enable Annotation Processing checkbox.

Click Apply. You should be prompted to rebuild the entire project; yes.

Reselect the Enable Annotation Processing checkbox. Apply. Rebuild the project.

The generated classes should now appear in .apt_generated.

I don't know exactly how this might interact with the Build Automatically setting on the project, but I think it's safe to call this a bug in Eclipse. I will see about filing a bug against Eclipse.

like image 141
pdx_jjb_nr Avatar answered Nov 11 '22 12:11

pdx_jjb_nr