def genCode = tasks.register("generateSrc") {
it.outputs.dir project.layout.buildDirectory.file("mycode1")
...
}
sourceSets {
main.java {
srcDirs genCode
}
}
Now tasktree shows correctly:
:compileJava
\--- :generateSrc
adding
sourceSets {
main.java {
srcDirs += project.layout.buildDirectory.file("mycode2")
}
}
breaks the above dependency.
And it is clear why:
srcDirs += "x" --> setSrcDirs(getSrcDirs() + "x" )
and getSrcDirs() return Set<File> that strips out the 'builtBy' information
Although seems trivial, took me several hours to figure out why.
(why just now ? because gradle 8 forces me to depend on generateSrc, which is great, and eliminates some of race conditions when running with --parallel)
What do you think ?