Configure only subset of subprojects


(jeppe) #1

Is it possible to configure only some subset of the sub projects.

I’m aware of subprojects{} but this applies to all the sub projects. Using project(’:p1’) {}, project(’:p2’){} seems repetitive.

Use case:

We have a number of sub projects, some which should be configured in the same way (dependencies etc). But there are other sub projects which should not use these settings

/Jeppe


(Erich Schroeter) #2

I suspect there are multiple solutions to this, but mine was to create a list of the subprojects I wanted to customize the configuration for and specify that list when calling configure. An example is below:

project.ext {
    subprojectList = subprojects.findAll{
        it.name == 'subprojectA' ||
        it.name == 'subprojectB' ||
        it.name == 'subprojectC'
    }
}
  configure(project.subprojectList) {
    // insert your custom configuration code
}

(jeppe) #3

Thanks,

Somehow I missed configure()

It’s even mentioned in the user’s guide.


(Benjamin Jansen) #4

You can simply pass projects to configure:

configure([project(':a'), project(':b'), project(':c')]) {
    // configuration
}

See the DSL reference docs on Project.configure().