Hello!
I got stuck with a problem, which I could not solve on my own, although it does not seem to be very exotic. I have tried solutions based on the docs and the suggested topics here, but could not get them to work.
Gradle version 6.0.1, Kotlin-DSL, multi module Java project with a Gradle plugin defined in buildSrc/
. The plugin executes a task srcgen
, which generates a Java source file in a submodule and writes it to build/generated/sources/srcgen/com/clemens/utils/Helper.java
.
In the submodule’s build.gradle.kts
, I have:
[...]
val compileJava by tasks
val srcgen by tasks
gradle.projectsEvaluated {
compileJava.dependsOn(srcgen)
}
java {
sourceSets["main"].java {
"build/generated/sources/srcgen"
}
}
[...]
The task srcgen
is executed before compilation and the file is generated in the submodule as build/generated/sources/srcgen/com/clemens/utils/Helper.java
. Thus, the source code generation works. But the compile task does not succeed, because the generated class/package cannot be found.
It seems, that I am missing something crucial. Hints are appreciated!
Clemens