Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle 5 does not pick annotation processor from project dependency #7941

Closed
ishaigor opened this issue Dec 5, 2018 · 10 comments
Closed

Gradle 5 does not pick annotation processor from project dependency #7941

ishaigor opened this issue Dec 5, 2018 · 10 comments

Comments

@ishaigor
Copy link

ishaigor commented Dec 5, 2018

My project has subprojects that are generating different artifacts. Among those, the subproject of interest are

  • model - contains annotations that will be used in other sub-projects
  • model-processor - contains annotation processor that generates sources for any class found with the annotations from model subproject
  • consumer - contains classes annotated with annotations from model subproject that should be accompanied by sources generated by annotation processor from model-processor subproject.

The build.gradle for consumer sub-project looks like

description = ''
dependencies {
    annotationProcessor project(':model-processor')

    compile project(':model')
}

Expected Behavior

I expect to find the generated sources under consumer/build/generated/source/apt/main

Current Behavior

I am not getting the files generated under consumer/build/generated/source/apt/main with the Gradle 5.0. I do get the annotation processor to work with the same build script and Gradle 4.10.2.

Context

I am trying to switch to Gradle 5 from Gradle 4.10.2 where the generation works. If I cannot get the annotation processor to work, I cannot migrate.

Steps to Reproduce (for bugs)

Clone https://github.com/ishaigor/annotation-processor-sample
Follow the steps in README

Your Environment

@big-guy
Copy link
Member

big-guy commented Dec 6, 2018

Could you share the build you're seeing this in?

@marcphilipp @oehme anything obvious to check?

@oehme
Copy link
Contributor

oehme commented Dec 6, 2018

Nothing comes to mind, this should work. We'll need a reproducible sample of the problem.

@ishaigor
Copy link
Author

ishaigor commented Dec 6, 2018

@big-guy, @oehme, @marcphilipp, I updated the description with the link to the sample that demonstrates the issue. Is there anything else needed in addition to the sample and the build scans?

@ishaigor
Copy link
Author

ishaigor commented Dec 7, 2018

Thank you for looking into the issue, one annotation processor was not declared: com.google.auto.service. Pushed correction out.

@ishaigor ishaigor closed this as completed Dec 7, 2018
@radzio
Copy link

radzio commented Apr 8, 2019

@ishaigor can tell more how you fixed your issue? I have the same and upgrading auto-service didn't help.

@ishaigor
Copy link
Author

ishaigor commented Apr 9, 2019

Take a look at ishaigor/annotation-processor-sample@d764591#diff-366f42343748f0d02147a45a53a2cf62 @radzio

@swathistudyblue
Copy link

I have multiple annotations in my project from lombok, slf4j, spring etc. And I created a new annotation and a processor for it. When I register this processor, all the other annotations start throwing compile errors. Is there anything specific I have to do to add to the existing list of processors.

@marcphilipp
Copy link
Contributor

@swathistudyblue You need to add the other processors as dependencies to the annotationProcessor configuration as well.

@oradkovsky
Copy link

Upgrading auto-service didn't help for me as well. Fighting build system instead of doing useful work :(

@Yukooo
Copy link

Yukooo commented Nov 30, 2020

Have the same issue, @oradkovsky have you managed to fix it. PS. All files are generated and placed in the $buildDir/generated/sources/annotationProcessor/java/main even the Intelijia Idea see those generated java files, but still, when I try to extend my class with a generated one, gradle can not find it.

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

No branches or pull requests

8 participants