On 12/01/2011, at 8:48 PM, Dan Haywood wrote:

> As I understand it, settings.gradle must list all projects in a multi-project 
> build.
> 
> What I'd like is something like a Maven profile so that I can use an env var 
> to run different subsets of this multiproject.
> 
> eg, in settings.gradle:
> projectA1
> projectA2
> projectB1
> projectB2
> 
> so that gradle build -D projectGroup=A (say) would just build projectA1, 
> projectA2.
> 
> Is there a common idiom for this?

I think there's a few approaches you could take:

1. Have code in settings.gradle to conditionally include the projects you want 
to build.

2. Keep all the projects in settings.gradle, and arrange them in a hierarchy to 
group them. Then, in the grouping projects, you can do something like:

task clean { dependsOn subprojects.clean  }
task assemble { dependsOn subprojects.assemble }

This way, you can run, say, 'gradle someGroup:assemble' to assemble all the 
subprojects of 'someGroup'

3. Similar to 2. above, but use sibling projects to do the grouping instead. In 
the grouping projects, you can do something like:

def projects = [project(':projectA'), project(':projectB')]

task clean { dependsOn projects.clean }

etc.

Personally, I would go with either option 2, or 3, depending on the meaning of 
the groups that you have.

For options 2 and 3, you can package up the logic into a plugin. In fact, we do 
plan to add an 'aggregate project' plugin at some point, which will solve this 
kind of problem.


--
Adam Murdoch
Gradle Developer
http://www.gradle.org
CTO, Gradle Inc. - Gradle Training, Support, Consulting
http://www.gradle.biz

Reply via email to