Many development workflows have certain builds that are run at various points in the workflow. For example, a developer might run a ‘dev’ or ‘precommit’ build before they commit their changes to version control. The CI server might then run the ‘commit’ build to build the software and run some integration tests. This might then trigger an ‘acceptance-test’ build that deploys the software to a QA environment and runs some acceptance tests. Finally, a release engineer might trigger the ‘release’ build to release the software and deploy it to production.
The idea is to capture this in the Gradle model. This has some advantages:
- It defines the abstract workflow steps for a project, with an implementation that be provided by plugins and to which conventions can be applied. * Configuration code can know early which type of build is being executed, and can do conditional configuration based on this.
Implementation-wise, you’ll probably be able to do the following things based on the build type:
- Define a sequence of tasks to execute when the build type is selected. Eg when the ciBuild build is run, run the clean task then the build task. * Add additional task dependencies. Eg when the ciBuild build is run, the testClasses task dependsOn the instrumentTestClasses task. * Conditional configuration. Eg when the release build is run, the version is 1.0.