Build types

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.

We’re starting to build this concept in ourselves. Nothing fancy, and it would be great to see first-class support.

Another requirement to consider would be some kind of daily or nightly build. This is where we are planning to put our periodic Sonar analysis. Maybe it shouldn’t be named for its frequency but I haven’t come up with something better yet.


The plan would be to add the general capability to allow you to define build types, but which doesn’t define any particular build types. We’d also add a plugin (or maybe a set of plugins) that define some conventional build types on top of this. A ‘nightly’ build might well be one such conventional build type we define.

I’m a little late in responding to this, but I think it’s a great idea. I’ve thought of this as allowing Gradle providing the “next level” of conventional builds.

Hello, I am interested in build types as well. Is there anything new for this in Gradle 1.4?

No, there is nothing in 1.4 or 1.5 for “Build Types”.

The Gradle Core project itself has a custom implementation that might be a good starting point for this: