Can I use a flag in to configure only subset of subprojects?


(alla.shamis) #1

How I can use a flag in configure()?

I don’t want use the projects names like in example http://forums.gradle.org/gradle/topics/configure_only_subset_of_subprojects

I’m looking something like this: (It’s not working correctly):

project.ext.specialType = false
..
configure(allprojects.findAll { it.specialType != 'true' }) {
    apply from: "specialConfig.property"
}
  ..
project proj1{
       specialType = true
}

(Baiyan Huang) #2

The reason it doesn’t work is because you set the specialType to the root project, which will automatically propagate to all its sub projects, so in effect you set all projects.

You can do something like:

project(':api').ext.specialType = true
  configure(allprojects.findAll { it.hasProperty("specialType") && !it.specialType }) {
    print it.name + "\n"
}

Notice if you access it.specialType directly, there will be exception if the project doesn’t have this property, so you need to use hasProperty to do the check.


(alla.shamis) #3

Thank you!