Skip to content
This repository has been archived by the owner on Jan 27, 2020. It is now read-only.

Annotation processor does not run in Eclipse multi-project #17

Closed
traggatt opened this issue Feb 17, 2016 · 8 comments
Closed

Annotation processor does not run in Eclipse multi-project #17

traggatt opened this issue Feb 17, 2016 · 8 comments
Labels

Comments

@traggatt
Copy link

I have a project where I'm trying to use Dagger 2 to generate DI sources in an Eclipse multi-project. I'm finding that the Dagger sources are not generated for my sub-project when I import the build into Eclipse.

I've replicated the issue in this standalone git repo: https://github.com/traggatt/AptTest

Notes:

  • When imported into Eclipse, I see the following Annotation Processor settings for sub-project aptProject:
    screen shot 2016-02-17 at 09 47 49
  • The build works from the command line. Since the Runner depends on Dagger generated class, DaggerTestComponent, the source code generation is clearly working ok in this context. (Indeed I can see the generated source code here: aptProject/build/generated/source/apt/main/aptProject.)

Before I converted my project into multi-project form, the Dagger sources generated into .apt_generated.

@traggatt
Copy link
Author

Just realised I forgot to mention, I'm using Eclipse Mars with its built-in gradle support.

@tbroyer
Copy link
Owner

tbroyer commented Feb 17, 2016

Hmm, I haven't tried Buildship but I suppose it's a similar issue as the Gradle integration in IntelliJ: Eclipse configuration to automatically enable annotation processing is done by tasks set as dependencies of the eclipse task, but I don't think Buildship actually runs the eclipse task.

You can manually run the eclipseJdtApt and eclipseFactorypath tasks to generate the appropriate configuration files in .settings/, but then you might also have to manually enable annotation processing in Eclipse.

@tbroyer
Copy link
Owner

tbroyer commented Mar 7, 2016

Just tried with your project:

  1. cloned it
  2. Imported it in Eclipse Mars
  3. Ran ./gradlew eclipseJdtApt eclipseFactorypath (you can also run the tasks from the Gradle Tasks view in Eclipse, after you set it up to Show All Tasks)
  4. Refreshed the project: configuration of annotation processing was OK (enabled, output in .apt_generated, factorypath properly populated)
  5. Rebuilt it (strangely, cleaning the project wasn't enough; disabling and re-enabling annotation processing worked though; didn't try closing/reopening Eclipse; didn't look further given it was working)

I also tried running the two tasks before importing the projects and it worked too; but again I had to force Eclipse to rebuild the project (first time fails, presumably because .apt_generated doesn't exist).
For as far as I can remember, I always had those kind of issues with Eclipse annotation processing (one of the reasons I personally switched to IntelliJ; YMMV)

@vogella
Copy link

vogella commented Mar 22, 2017

disabling and re-enabling annotation processing worked though; didn't try closing/reopening Eclipse

Reported this to JDT https://bugs.eclipse.org/bugs/show_bug.cgi?id=514055

@thekalinga
Copy link

@vogella Is annotation processing working for you? or you also moved away from eclipse?

@thekalinga
Copy link

thekalinga commented Apr 24, 2018

I opened another issue this time with mapstruct. Mine does not work even after turning annotation processors on or off

#79
spring-attic/spring-ide#273

@vogella
Copy link

vogella commented Apr 24, 2018

@thekalinga
Copy link

@vogella Thanks. I'll check & see whats the difference between yours and mine

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants