I’m creating a plugin that uses some existing code generation library to provide some classes to the project that uses the plugin. The output of that library is both some plain Java source plus some generated .class files (for some bits, that library outputs only bytecode, no source code).
I put the output of the library into build/generatedSource and build/generatedClasses. Now I need to tell Gradle that A) files in build/generatedSource need to be compiled and B) the files in build/generatedClasses need to be put onto the classpath and included in the assembled JAR.
But I cannot figure out how to get B) right. I can tell the library to put the generated .class files into build/classes/java/main, but it feels like a hack to me. Putting them into build/classes/something/main would make sense to me, but how do I then tell Gradle to treat that directory similar to build/classes/java/main?
Also, ideally, the Eclipse plugin would understand that there is another directory with already compiled .class files that it needs to include in the buildpath
It usually takes me ages to translate even tiny bits of Groovy code to Java, just don’t know where to look it up and googling usually gives many many false positives. So for any future visitors of this thread, just for the sake of completeness, how it can be done in Java: