You need to break the chicken or egg problem. Use configurations to solve the problem.
project(':service') {
configurations {
allgenerated
}
dependencies {
allgenerated project(path: ':a', configuration: 'generated')
allgenerated project(path: ':b', configuration: 'generated')
allgenerated project(path: ':c', configuration: 'generated')
}
}
project(':a') {
configurations {
generated
allgenerated
}
dependencies {
generated files({tasks.generate})
allgenerated project(path: ':service', configuration: 'allgenerated')
}
task generate {
outputs.dir "$buildDir/generated"
doLast {
// this task just generates for project 'a'
}
}
task doStuffWithAllGenerated {
dependsOn configurations.allgenerated
doLast {
// this task can "see" all the generated stuff
configurations.allgenerated.each {...}
}
}
}