BT

New Early adopter or innovator? InfoQ has been working on some new features for you. Learn more

Gradle 2.5 Does Continuous Builds

| by Abel Avram Follow 4 Followers on Jul 24, 2015. Estimated reading time: 2 minutes |

Gradle 2.5 has been announced this month including a number of incubating features, such as Continuous Builds, Dependency Substitution Rules, Progress Events, Google Tests, and others.

Continuous Builds

One of the most interesting features introduced in Gradle 2.5 is support for continuous builds. When started with the switch –continuous or –t, Gradle will perform the build then watch for changes of the main source code or tests and automatically initiate the same build when a change occurs. If the project’s source code changes, Gradle will recompile it and execute the tests. If the source of the tests changes, then it will recompile the tests and execute them. Only the affected tasks are executed. Changes of build scripts do not initiate another automatic build. A manual build command needs to be issued for those changes to be considered. In the future, the team intends to include remote repositories in the continuous build process.

There are some limitations: changes to the files read during the configuration phase of the build do not trigger a new build. Also, Gradle uses WatchService to monitor for file system changes, which means it requires JDK 1.7 or later to run. On Mac OS X, Gradle relies on OS’s file system polling mechanism which is considered inefficient and can cause deadlock when many files are watched. Creating files in the target directory of a symbolic link, creating/removing symbolic links to directories or modifying/deleting the target of a symbolic link will not trigger a new build.

Dependency Substitution Rules

Dependency substitution rules allow replacing a dependency on a project with an external module, as shown in the following snippet taken from the user guide:

resolutionStrategy.dependencySubstitution {
  substitute project(":api") with module("org.utils:api:1.3")
}

This is helpful to speed up a multi-project build, enabling downloading some dependencies from external repositories rather then building them.

Substitutions can be defined the other way around, replacing an external module with a local project. This could be useful when attempting to build with a local version of a dependency for testing purposes. The substitution can specify the version of the module or not:

resolutionStrategy.dependencySubstitution {
  substitute module("org.utils:api") with project(":api")
  substitute module("org.utils:util:2.5") with project(":util")
}

Progress Events

The addProgressListener(ProgressListener) method can be used to register listeners to various build events triggered when the task graphs is constructed, when task execution is started/stopped, or when test execution is started/stopped.

Google Tests

Gradle now has a plug-in providing rudimentary support for the compilation and execution of Google Tests. Plans for the future include better HTML reporting, real-time feedback on test execution and support for other testing frameworks.

Other

Other new features in Gradle 2.5 are: simpler default dependencies, precompiled header support, and improvements of the managed model. A number of features have been deprecated, and a number of issues have been fixed. There is also a number of potential breaking changes.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT