I’m using Gradle 7.4.2.
Setup:
- multiple subprojects building libraries (i.e. A, B, C, then D that includes A+B+C as dependencies)
- some generated sources in the subprojects
What I Want:
- single library (i.e. D-library.jar) that includes most of the subprojects (to push to Artifactory)
- single D-sources.jar that includes all the related sources
I kindof have this working by adding the following to my D subproject:
sourceSets {
main {
java {
srcDirs += "$buildDir/generated"
}
}
}
dependencies {
project(":A")
project(":B")
project(":C")
}
java {
withSourcesJar()
}
But I get a warning at build time like:
“Execution optimizations have been disabled for task ‘:D:sourcesJar’ to ensure correctness due to the following reasons:
Task ‘:D:sourcesJar’ uses the output of task ‘:D:compileJava’ without declaring an explicit or implicit dependency…”
So I think I need to declare dependencies formally against the “generated” directories in the other subprojects, but I don’t see a syntax to do that.
I tried
java {
inputs "..."
}
and
java {
withSourcesJar() {
inputs "..."
}
}
but not of that works.
Can someone point me in the right direction?