Is the gradle "separate module per source set" option incompatible with annotation processing?

Answered

When importing a gradle project, is the "separate module per source set" option incompatible with enabling annotation processing? When I'm using one module per source set, enabling annotation processing either puts the generated source in the out/classes/generated directory, or in the src/generated directory. Either way the IntelliJ editor is not able to see the generated java files. There doesn't seem to be another option.

I'm attempting to import a gradle project that uses the Immutables library (https://github.com/immutables/immutables). I need to use a separate module per source set because each source set has a classpath with different library versions. Is what I'm trying to do not possible in current versions of IntelliJ?

0
15 comments
Avatar
Permanently deleted user

That looks similar to my issue, but I'm on 2017.2.6 which, according to the bug description, isn't impacted. I tried using paths like "../../generated" which moves the generated source outside of the out directory, but I still have the same issue. Everything builds in IntelliJ without errors, but the editor can't see the generated source so it shows "Cannot resolve symbol" anywhere one of the generated classes is used.

0

Did you try the current EAP build?

0
Avatar
Permanently deleted user

Update: I was able to get everything working correctly by setting "Store generated sources relative to: Module content root" under Preferences -> Build, Execution, Deployment -> Annotation Processors, but I still had to manually set every generated sources directory as a source directory in Project Structure -> Modules.

Is it expected behavior that I have to add every generated sources directory for each module manually?

0
Avatar
Permanently deleted user

I did not try the EAP build yet. I'll try it now.

0
Avatar
Permanently deleted user

Unfortunately the current EAP gets a NullPointerException in the gradle plugin while trying to import my gradle project.

0

Thanks for the information. Please submit the NPE at https://youtrack.jetbrains.com/issues/IDEA.

0
Avatar
Permanently deleted user

I added IDEA-184484 for the EAP. For now, do you know any version of IntelliJ that works with both the gradle "separate module per source set" option and annotation processing with code generation? Thanks for the help on this.

0

I've asked the responsible developer to comment, but it may take some time because of the long holidays.

0
Avatar
Permanently deleted user

Are there any other ideas on this? I'm still not having any luck with the EAP builds.

0

Have you tried 2018.1 EAP: https://www.jetbrains.com/idea/nextversion/ ? Fix for the related issue should be included there.

0
Avatar
Permanently deleted user

I have tried both the 2017.3 and 2018.1 EAPs. I'm not able to import my gradle project in either of them. I filed IDEA-184484.

Is annotation processing with "separate module per source set" fixed in these versions?

0
Avatar
Permanently deleted user

It says that IDEA-183336 is fixed in build 173.4168, but I upgraded to 2017.3.4 with build 173.4548.28 and I'm having the exact same issue.

Is there a different fix in 2018.1?

0

Is it possible to provide sample project example for investigation?

0

Please sign in to leave a comment.