During what I would call “casual glancing” on the gradle src files, I found the BuildTypes.groovy class.
After digging, I find it pretty cool
For those wondering, it is used in the main build.gradle file of the gradle distribution
extensions.buildTypes = new BuildTypes(project)
buildTypes {
fullTest “runtimeTests”, “runtimeIntegTests”, useIncomingDistributions: true, defaultIntegTestExecuter: “forking”, testAllVersions: true
…
}
Thanks to groovy goodness, if the task ‘fullTest’ is called, it will add the provided string as tasks to the task that will be executed, and also the provided map elements as project properties.
All the various buildTypes are regrouped in a task group called ‘Build Type’
I’m surprised that this feature is not publicly exposed in the user guide, because it’s pretty cool.
As a build script writer, I tend to create meta tasks to regroup more low level tasks, and tell my users to launch only those meta tasks.
=> This is exaclty what the BuildTypes do !
Some improvements I could think of for this functionality are:
- the possibility to easily add a description to each BuildType task
- the possibility to hide all the other tasks (to force users to launch predefined build ‘stories’, i.e. tasks organized by the build writers in a certain way)