In my multi-project build, in the root build.gradle, I’d like to add some custom configuration for selected projects to be evaluated after the subprojects{} block. Putting that section last in the file doesn’t accomplish that - I get an error showing that a plugin applied in the subprojects block is not yet applied when the configure(selected){} block is run. Nesting the configure(selected) block within subprojects{} doesn’t work either; everything in the block is evaluated for all subprojects. So how is it done?
That should work.
Here’s an example:
build.gradle
:
subprojects {
apply plugin: 'java'
println "Configuring $name"
}
def someProjects = subprojects.findAll { it.name.startsWith("special") }
configure(someProjects) {
println "Configuring $name special"
jar {
// configure jar task
println "Configuring jar for $project.name"
}
}
task print
settings.gradle
:
include 'specialA', 'B', 'specialC', 'D'
gradle print
produces this output:
Configuring B
Configuring D
Configuring specialA
Configuring specialC
Configuring specialA special
Configuring jar for specialA
Configuring specialC special
Configuring jar for specialC