Gradle Release Notes

Version 6.1.1

The Gradle team is excited to announce Gradle 6.1.1.

This release supports a relocatable dependency cache for speeding up ephemeral CI builds, makes compilation order between Java, Groovy, Kotlin and Scala classes configurable for polyglot builds and kicks off a new set of downloadable samples for newcomers.

There are also several bug fixes, conveniences for Gradle plugin authors and more.

We would like to thank the following community contributors to this release of Gradle: Mark Nordhoff, Kazuki Matsuda, Andrew Malyhin, Emmanuel Guérin, Nicholas Gates, Bjørn Mølgård Vester, Johnny Lim, Benjamin Muskalla, Ian Kerins, Vladimir Sitnikov, Michael Ernst, Nelson Osacky, Dmitriy Konopelkin, and Steven Crockett.

Table Of Contents

Upgrade Instructions

Switch your build to use Gradle 6.1.1 by updating your wrapper:

./gradlew wrapper --gradle-version=6.1.1

See the Gradle 6.x upgrade guide to learn about deprecations, breaking changes and other considerations when upgrading to Gradle 6.1.1.

For Java, Groovy, Kotlin and Android compatibility, see the full compatibility notes.

Ephemeral CI: Reuse Gradle's Dependency Cache

It's increasingly common for CI/CD pipelines to run with ephemeral build agents. Ephemeral build agents are single-use and can improve reliability by reducing interactions between builds. Each agent is thrown away at the end of the build and no state is reused between builds.

Without optimizations, this results in significantly longer build times because local caches like Gradle's dependency cache has to be refilled for each build. Every build pays the cost of re-downloading all dependencies.

Starting with Gradle 6.1, the dependency cache can be copied to another directory or host. When a copy of the dependency cache is made available to an ephemeral build agent, builds will no longer need to access the network to download artifacts or metadata contained in the cache.

See the documentation for more details.

Polyglot JVM builds: Defining compilation order between languages

Gradle supports combining multiple JVM language in a single project, like mixing Java, Scala, Groovy and Kotlin source files. Each language has its own set of sources and a compile task. Previously, the relationships between the languages were defined in a way that was hard to change.

With Gradle 6.1, the relationship between compilation tasks is now fully expressed through the classpath property of the tasks. This can be used to change the relationship between Java, Groovy, Kotlin and Scala compilation tasks to whatever order is required by the project.

For example, when combining Groovy and Kotlin in the same project, you can make Kotlin classes depend on Groovy classes like this:

tasks.named('compileGroovy') {
    // Groovy only needs the declared dependencies
    // and not the output of compileJava
    classpath = sourceSets.main.compileClasspath
}
tasks.named('compileKotlin') {
    // Kotlin also depends on the result of Groovy compilation 
    // which automatically makes it depend on compileGroovy
    classpath += files(sourceSets.main.groovy.classesDirectory)
}

See the documentation for more details.

Downloadable Gradle Samples

In addition to tutorials and guides and an extensive user manual, Gradle now provides an index of samples to demonstrate different kinds of projects that can be built with Gradle, like Kotlin or Spring boot. The samples also show common problems that can be solved using the Groovy or Kotlin DSL, like adding integration tests to a Java project. Each sample comes bundled with a Gradle wrapper, so you don't even need to have Gradle installed before trying them out.

These samples are tested with the same version of Gradle as the documentation. More samples will be added over time. If you have any suggestions for a problem or use case you think would make a good sample, please open a new issue.

Groovy compilation support for method parameter names with JDK8+

Gradle 6.1 supports compiling Groovy code and including method parameter names.

This was contributed by Andrew Malyhin.

Improvements for plugin authors

Finalize property value only when the value is queried

In previous Gradle releases, certain Gradle types, such as Property or ConfigurableFileCollection, provided a finalizeValue() method that eagerly calculated the final value for a property and prevented further changes.

When a task starts running, Gradle automatically finalizes task properties of these types, so that the same value is seen by the task's actions and Gradle's build caching/up-to-date checks. This also avoids calculating the property value multiple times, which can sometimes be expensive. Plugins can also use finalizeValue() to finalize other properties, such as a property of a project extension, just prior to querying the value.

In this release, these types gain a new finalizeValueOnRead() method. This method is similar to finalizeValue(), except that the final value is calculated when the value is queried rather than immediately. Plugins can use this method when a property value may be expensive to calculate or when the value may not have been configured to ensure that all consumers of the property see the same, final, value from that point onwards.

Please see the user manual for more details.

New managed property types

Gradle 5.5 introduced the concept of a managed property for tasks and other types, where Gradle provides an implementation of the getter and setter for an abstract property defined on a task, project extension, or other custom type. This simplifies plugin implementations by removing a bunch of boilerplate.

In this release, it is possible for a task or other custom type to have an abstract read-only property of type DomainObjectSet<T>.

Please see the user manual for more details.

New factory methods

The ObjectFactory type, which plugins and other custom types use to create instances of various useful types, has several new factory methods to create certain Gradle types that could only be created using internal APIs in previous releases:

Please see the user manual for more details.

Improvements for Gradle tooling providers

Tooling API: TestLauncher can run specific Test task tests

The TestLauncher interface in the Tooling API could already launch tests by specifying the name of the test classes or methods; however, if there are multiple Test tasks, then all Test tasks would be executed.

For IDEs, developers usually want to execute only one task at a time. Gradle 6.1 introduces a new API to execute tests with specific Test task using the withTaskAndTestClasses() and withTaskAndTestMethods() methods.

Fixed issues

Known issues

Known issues are problems that were discovered post release that are directly related to changes made in this release.

External contributions

We love getting contributions from the Gradle community. For information on contributing, please see gradle.org/contribute.

Reporting Problems

If you find a problem with this release, please file a bug on GitHub Issues adhering to our issue guidelines. If you're not sure you're encountering a bug, please use the forum.

We hope you will build happiness with Gradle, and we look forward to your feedback via Twitter or on GitHub.