Hey all, I have a multi-module Android project wh...
# gradle
m
Hey all, I have a multi-module Android project which contains multiple applications. Each one of those application modules includes a set of interfaces that an annotation processor will use to generate code based on the class-path of this module. Today, those interfaces are duplicated, and I can't move them to a shared module due to the code generation requirement (class-path). I tried to create a shared folder and include it as a source directory to all those application modules (I know this sounds ridiculous, but I did not find another way...) but, for some reason, only one of the application modules randomly recognized the folder as part of it (sourceroot) and the others fails (both at IDE and compilation level). Is there a way to include a piece of code in multiple modules to be compiled and processed inside the included module? I appreciate any help you can provide.
v
If you are working on *nix you could probably symlink the directory which should then also work in the IDE. In Gradle itself it should probably work to just reference the sources multiple times if done correctly, but it could well be that it is not IDE-compatible.
m
In Gradle I tried to use sourcesets/srcDirs but looks like a sourcesets can have only one "source root" and therefore, it failed. :-(
v
What do you mean with can only have one source root? I just recently wrote a build where the main source set has checked in code in
src/main/java
and generated code in
build/generated-sources/<taskName>/java
and it works like a charm in Gradle and the IDE.
m
@Vampire sorry, I mean't "content roots". Looks like IntelliJ is the one "bugging" the set up, not Gradle: https://youtrack.jetbrains.com/issue/IDEA-211101 😞
v
Yes, as I said, that it does not work in IntelliJ is known, or at least I knew that. But you said it also does not work in Gradle and that is what confuses me because in Gradle it should work just fine.
👍 1