The Gradle development team is excited to release Gradle 2.6, with some shiny new features and many under the hood improvements.

This release brings Gradle support to the Play framework ecosystem. If you build Play applications, you can now do so with Gradle, taking advantage of the available features and capabilities. In particular, Play developers with more sophisticated dependency management or orchestration requirements may find building their apps with Gradle to be particularly appealing.

The addition of Play support to Gradle will bring benefits for non-Play users as well. Gradle supports development-time reloading of a Play application, leveraging the continuous build capabilities in Gradle 2.5 to be “change aware”. This mechanism will evolve into a general management capability, providing continuous reload features for other types of containers and applications.

The new “Gradle TestKit” provides an official mechanism for testing custom plugins which will greatly improve the Gradle plugin development experience. This initial version of the TestKit focuses on executing real builds and asserting the result (i.e. functional testing). Expect the TestKit to improve and expand over coming releases.

New and noteworthy

Here are the new features introduced in this Gradle release.

Play Framework Support incubating feature

Gradle can now build Play applications for Play version 2.3.x and 2.4.x. The new play plugin allows users to build, test, run and package Play applications.

It includes support for:

Compiling Scala and Java controllers, tests, and model classes

Processing routes files

Processing Twirl templates

Compiling CoffeeScript assets

Minifying JavaScript assets

Running tests with JUnitRunner

Running applications in development mode with hot reloading

Staging and creating Play distribution packages

Compatibility with Play 2.4.x is limited. The play plugin does not work with a few new build-related features in 2.4. Specifically, Gradle does not allow you to configure reverse routes or use "injected" routes generators. Future releases will add support for these features as well as other features and versions of the Play Framework.

When running a Play application as part of a continuous build, changes to the source are reflected in the running app automatically… no restart required. This facilitates a fast development cycle. The mechanism empowering this “hot reloading” will be made generally available to other types of applications and services in future versions of Gradle.

See the User Guide as well as the sample builds delivered with the Gradle distribution for more information on using the play plugin.

Support for functionally testing Gradle plugins

This release brings the initial version of, the long awaited, official support for functionally testing Gradle plugins. That is, being able to programmatically execute a contrived build leveraging a plugin under development as part of the plugin's build. This functionality is being delivered as part of the new Gradle TestKit.

Many community members stepped up and filled the void created by the absence of a built in way to do this. Notably, the folks at Netflix contributed the very popular Nebula Test as part of their Nebula Project. The functionality provided by this and other similar projects will over time be rolled into the Gradle TestKit.

The following example demonstrates the use of the TestKit API in a test method based on the test framework Spock:

def "hello world task prints hello world" () { given : buildFile << """ task helloWorld { doLast { println 'Hello world!' } } """ when : def result = GradleRunner . create () . withProjectDir ( testProjectDir . root ) . withArguments ( 'helloWorld' ) . build () then : result . standardOutput . contains ( 'Hello world!' ) result . task ( ":helloWorld" ). outcome == SUCCESS }

See the new Gradle TestKit user guide chapter for more information.

Tooling API TestLauncher incubating feature

This releases introduces a new TestLauncher interface for launching tests using the Tooling API.

The following is an example of using the new API…

ProjectConnection connection = GradleConnector . newConnector () . forProjectDirectory ( new File ( "someFolder" )) . connect (); try { connection . newTestLauncher () . withTests ( descriptor1 , descriptor2 ) . launcher . withJvmTestClasses ( "example.MyTest" ) . addProgressListener ( new MyTestListener (), EnumSet . of ( OperationType . TEST )) . setStandardOutput ( System . out ) . run (); } finally { connection . close (); }

See the Javadoc for ProjectConnection and TestLauncher for more information on using the new TestLauncher API.

Rule based model configuration reporting improvements incubating feature

Gradle 2.5 brings significant usability enhancements to the new Rule based model configuration mechanism, through better reporting.

The in-built “Model report” now exposes much more information about the build model, including:

The Java type of each model element

A string representation of the value of each model element

Which rule created each model element

Which rules were involved in configuring a model element and the order in which they were applied

The model report makes it much easier to see the effective configuration of the build, and comprehend how it came to be. Future improvements to the model report will include:

Improved names/identifiers for rules

Visualisation of dependencies between elements

Alternative formats that provide more control over level of detail

Greater coverage of the total build model

In addition to the model report improvements, rule “binding failure” error messages have also been improved. A binding failure occurs when the declared subject or any of the inputs for a given rule cannot be found when the rule is required. Such a failure is fatal to the build.

The new format presents vital debugging information such as:

Which inputs or subjects could not be bound.

Where, in the build script, the missing rule dependency was identified.

The model path to the model element with the failure.

Which method parameter, on a method rule, could not be bound.

Suggestions as to which inputs/subjects could be used to successfully bind.

e.g. Consider the following rule configuration which is invalid because of an unsatisfied input: bar .

class Rules extends RuleSource { @ Model Integer foo ( @ Path ( "bar" ) Integer bar ) { return 22 } } apply type : Rules

The resulting error message gives some clear insight into what went wrong and why:

The following model rules could not be applied due to unbound inputs and / or subjects : Rules #foo inputs : - bar Integer ( parameter 1 ) [ * ] [ * ] - indicates that a model item could not be found for the path or type .

In the above example, the error occurred due to there being no model element at path bar .

This is an area of active development and will continue to improve and evolve in coming Gradle releases.

Support for verifying Gradle wrapper distribution download against SHA-256 hash

It is now possible to verify the integrity of the Gradle distribution used by the Gradle wrapper against a known checksum. This provides an extra level of assurance that the Gradle runtime is exactly the intended version.

To enable verification you need only specify a distributionSha256Sum property in your project's gradle-wrapper.properties file.

distributionSha256Sum = e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

Please see section Verification of downloaded Gradle distributions of the User Guide for more information.

This feature was contributed by Dominik Schürmann.