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

[Question] Does bloop support annotation processing for a pure Gradle Java project? #2007

Open
jdneo opened this issue Feb 21, 2023 · 3 comments
Labels
bug A defect or misbehaviour. java Pull requests that update Java code

Comments

@jdneo
Copy link

jdneo commented Feb 21, 2023

Hi team 👋,

I was recently aware of this build server and was playing around with it.

I tested it toward this project: https://github.com/mapstruct/mapstruct-examples/tree/main/mapstruct-on-gradle.

It's a Gradle project with pure Java codes.

The Bloop server works quite well, but it seems that the server won't include the generated folder build/generated/sources/annotationProcessor when dealing with the build target sources request. Is there anything I missed?

Thanks.

@ckipp01
Copy link
Member

ckipp01 commented Feb 21, 2023

Hey @jdneo thanks for the question! It may just be the gradle plugin doesn't indeed correctly export the generated sources directory, meaning that Bloop doesn't know about them. I tried to reproduce this with the example repo you have, but I actually can't get the repo to build. Do you by chance have a more minimal reproduction that I could try this with?

@Arthurm1
Copy link
Contributor

@ckipp01 Gradle version being used is 6.2 so you have to use JDK 13 or lower to build with ./gradlew assemble
Or change the gradle/wrapper/gradle.properties file to contain distributionUrl=https\:https://services.gradle.org/distributions/gradle-7.6-bin.zip to upgrade and use up to JDK 19

I can get this to build with Gradle on the command line using ./gradlew assemble.

I can also get it to compile under Bloop with the warning Could not determine source for class org.mapstruct.example.SourceTargetMapperImpl but I'd expect that.

The javac options look correct as the generated sources are added using...

-s
  E:\mapstruct-examples\mapstruct-on-gradle\build\generated\sources\annotationProcessor\java\main

I can't compile under Metals though. The error is plug-in not found: semanticdb.

The plugin seems to be setup correctly with -Xplugin:semanticdb -sourceroot:E:\mapstruct-examples\mapstruct-on-gradle -targetroot:javac-classes-directory added to the javac options and E:\mapstruct-examples\mapstruct-on-gradle\null\bloop\cache\semanticdb\com.sourcegraph.semanticdb-javac.0.8.9\semanticdb-javac-0.8.9.jar added to the classpath (which is where the jar exists even though the null is odd)

I've tried this with the https://github.com/immutables/immutables annotation processor instead and I get the same issue.

So there seems to be some clash between annotation processors and the semanticdb plugin.

I don't really know this area well enough to know if something is missing from the javac options/classpath or whether there is actually an issue with the plugin. Do annotation processors work in SBT/Mill with Metals+Bloop+Java?

@jdneo
Copy link
Author

jdneo commented Feb 22, 2023

As @Arthurm1 suggested, you can either update the gradle version in the gradle.properties or update the JDK version. A compatibility matrix can be found here: https://docs.gradle.org/current/userguide/compatibility.html.

@tgodzik tgodzik added bug A defect or misbehaviour. java Pull requests that update Java code labels Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A defect or misbehaviour. java Pull requests that update Java code
Projects
None yet
Development

No branches or pull requests

4 participants