On 27/03/10 9:13 PM, Alex Shneyderman wrote:
Hi, all!
I am trying to figure out how the build system of a project I am
working on (ant based) would look like in Gradle. Currently, system
has tons of fairly small modules. Production deploys all of them, but
during development we deploy only a hand-full of modules. Current ant
based system is able to produce a set of deployable artifact based on
command line parameter passed to the build. I can include as many
modules as I would like or we have some shortcuts that can deploy a
pre-defined/pre-calculated set of modules.
The question is how do I configure these subsets in Gradle? I am
reading about settings.gradle but it seems that you have only one
chance of telling gradle of what modules are in this project. It feels
like I would need something like configuration of dependencies, in the
settings.gradle. So if I want to build a subset of modules it could be
specified in some form and picked up by Gradle. Or maybe there is a
way already and I am not seeing it? Any pointers, or samples of this
being done (if done already) would most appreciated.
There's a bunch of different ways you could do this, depending on what
you need exactly. Here are some possibilities:
1. Add a task for each set of projects you'd like to build/deploy.
This way, all the projects are available in the build, so you can build
any ad hoc combination that you choose. For any combination that you
choose - predefined or ad hoc - Gradle will build only the pieces that
you need.
For example, in your root build.gradle:
task buildCombo1 {
dependsOn 'project1:build', 'project2:build'
}
task buildCombo2 {
dependsOn ...
}
Then you can run things like: 'gradle buildCombo1' or 'gradle
buildCombo1 project7:build'
It is quite easy to automate the definition of these tasks.
2. Dynamically choose which projects to include in the build
You can add some logic in the settings.gradle file to determine which
projects to include, based on command-line arguments.
For example, in your settings.gradle:
include 'project1'
if (startParameter.projectProperties['combination'] == 'combo1' ) {
include 'project2'
include 'project3'
}
The you can run things like 'gradle -Pcombo=combo1 build' to build a
particular combination of projects.
3. Add a project for each combination.
Similar to 1, but each combination gets its own project. This would
allow you to use a custom plugin to define what tasks to add for a given
combination. This is similar to the
$gradleHome/samples/customBuildLanguage sample, and can be both very
expressive and powerful.
For example, in the root build.gradle, you might do:
project('combo1' ) {
usePlugin(MyCustomPlugin)
include('project1')
include('project2')
}
project('combo2' ) {
usePlugin(MyCustomPlugin)
include('project2')
include('project3')
}
this might add a 'clean', 'test', 'build', and 'deploy' task for each
combination, so you can run things like 'gradle combo1:clean combo1:deploy'
Of course, you can also combine these options, they aren't mutually
exclusive.
--
Adam Murdoch
Gradle Developer
http://www.gradle.org
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email