Correct incremental builds

I recently read the Bazel build tool from Google, and from what I understood, you do not need to use clean. This can be read a bit about in the User Guide under “Correct incremental rebuilds”.

I wonder if the same thing can be achieved with gradle. The problem with gradle, is that if I delete a file, it will not remove the corresponding file in the output. If gradle where to clean output folders of tasks whose input have changed, my guess is that the need for clean builds would be less.

If a project has multiple modules, you would only need to rebuild those modules that have changed, and their downstream dependencies. This could speed up the build process drastically.

So far I have not dared leaving the build to run incrementally on our build server. We run all our code through gerrit for code review, and each patch is compiled. Compile time for some of the modules has reached 10-15 minutes, which makes for a slow process. We do need to improve and break up our codebase more to improve build times. But if we could reliably run without clean, this would improve our build time.

Perhaps there are features already in gradle to support this.

One of gradle core concepts is it’s [up-to-date checking] ( so ‘dirty’ builds can skip tasks where the inputs haven’t changed.

Gradle has (incubating) support for [IncrementalTaskInputs] ( so that tasks can choose to update only what has changed.

The java plugin has (incubating) support for options.incremental = true