Gradle Release Notes

Version 4.7

The Gradle team is pleased to announce Gradle 4.7.

First and foremost, Gradle's incremental Java compiler can now run annotation processing incrementally. No user-facing configuration is necessary, but processor authors need to opt-in. We request annotation processor authors read the documentation for this feature and contact the Gradle team via the forum for assistance.

Java enthusiasts will be happy to read that this release supports running Gradle builds with JDK 10.

Gradle log output is now grouped by task for non-interactive executions, making interleaved logs a thing of the past on CI. It also enables build scan plugin v1.13 to show logs per task:

build scan logs by task

Moving on to other areas of user experience: running tests is further improved as failed tests now run first. Together with the --fail-fast option it provides the quickest possible feedback loop.

This release introduces an incubating new capability for Kotlin DSL users: precompiled script plugins. This means that you can create a Kotlin DSL script within a regular Kotlin source set and get the benefits of binary plugins. For example, src/main/kotlin/nyan.gradle.kts could be used as plugins { id("nyan") }.

Kotlin DSL v0.16 also includes Kotlin 1.2.31, a more consistent API, better IDE support, and more. See details and examples in the Kotlin DSL v0.16 release notes.

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

Table Of Contents

Upgrade instructions

Switch your build to use Gradle 4.7 quickly by updating your wrapper properties:

gradle wrapper --gradle-version=4.7

Standalone downloads are available at gradle.org/releases.

New and noteworthy

Here are the new features introduced in this Gradle release.

Incremental annotation processing

Gradle's incremental Java compiler can now also run annotation processing incrementally. No user-facing configuration is necessary, but processor authors need to opt in. If you are a processor author, have a look at the user guide to find out how to make your processor compatible.

Logs grouped by task for non-interactive executions

Gradle has two basic console modes, which determine how Gradle formats the text output it generates: The 'plain' console mode is used by default when Gradle is running without without an associated console, for example from an IDE or a CI build agent, and the 'rich' console is used by default when Gradle is running with an associated console, for example when running from the command-line.

In previous releases, the rich console had some features that the plain console was missing. These are now available for the plain console as well. In this Gradle release, the plain console groups the output from each task under a header rather than interleaving the output. This makes diagnosing issues on CI using the log output much easier.

Rerun failed tests first

Now, in the subsequent test, Gradle will execute the previous failed test class first. With --fail-fast option introduced in 4.6, this can provide a much faster feedback loop for development.

Support for resources and test resources in the IDEA plugin

The IDEA plugin now automatically marks your Java resource directories (e.g. src/main/resources) as resources in the IDEA project hierarchy. From now on it is also possible to mark additional directories as resources or test resources in the IDEA module:

idea {
    module {
        //and some extra resource dirs
        resourceDirs += file('src/main/some-extra-resource-dir')

        //and some extra test resource dirs
        testResourceDirs += file('src/test/some-extra-test-resource-dir')
    }
}

Support for mapped nested inputs

When dealing with task inputs, it may be that not all values are known upfront. For example, for code quality plugins like FindBugs, it is possible to configure the creation of different kinds of reports, such as generating an HTML report and a plain text report.

Each report may have a different output location and the report is only created when enabled. For example, the HTML report is generated to findbugs.html, while the XML report is generated to findbugs.xml.

Before allowing mapped nested input, the task needed to collect the output files from the different enabled configured reports "by hand":

@OutputFiles
Map<String, File> getEnabledFileReportDestinations();

@Input
SortedSet<String> getEnabledReportNames();

With the ability to declare the map of enabled reports as an input, it is now possible to do this:

@Nested
public Map<String, Report> getEnabledReports() {
    return getEnabled().getAsMap();
}

This causes each report to be added as a nested input with the key as a name. For example, the output directory of the FindBugs HTML report is added as reports.html.destination by the above declaration.

Support for named nested inputs

When annotating an iterable with @Nested, Gradle already treats each element as a separate nested input. In addition, if the element implements Named, the name is now used as property name. This allows for declaring nice names when adding CommandLineArgumentProviders, as for example done by JacocoAgent.

As a result, it is easier to track down which input changed:

without named with named

Default JaCoCo version upgraded to 0.8.1

The JaCoCo plugin has been upgraded to use JaCoCo version 0.8.1 by default.

Continuing development of Native ecosystem

The Gradle Native project continues to improve and evolve the native ecosystem support for Gradle.

Promoted features are features that were incubating in previous versions of Gradle but are now supported and subject to backwards compatibility. See the User guide section on the “Feature Lifecycle” for more information.

The following are the features that have been promoted in this Gradle release.

De-incubation of Google repository shortcut method

The method RepositoryHandler.google() has been promoted.

De-incubation of Project#findProperty

See javadocs for details

De-incubation of several Groovy compile options

The following Groovy compile options have been promoted:

Fixed issues

Deprecations

Features that have become superseded or irrelevant due to the natural evolution of Gradle become deprecated, and scheduled to be removed in the next major Gradle version (Gradle 5.0). See the User guide section on the “Feature Lifecycle” for more information.

The following are the newly deprecated items in this Gradle release. If you have concerns about a deprecation, please raise it via the Gradle Forums.

Change of default Checkstyle configuration directory

With this release of Gradle, the Checkstyle configuration file is discovered in the directory config/checkstyle of the root project and automatically applies to all sub projects without having to set a new location for the configDir property. The Checkstyle configuration file in a sub project takes precedence over the file provided in the root project to support backward compatibility.

Special casts for FileCollection using the Groovy as operator

Previously it was possible to cast a FileCollection instance to some special types using the Groovy as keyword. This is now discontinued.

Using the as operator to cast FileCollection to Object[], Collection, Set and List is still supported.

Potential breaking changes

Gradle console output changes

The plain console mode now formats output consistently with the rich console, which means that the output format has changed. For example:

This may break tools that scrape details from the console output.

Changes to native compilation, linking and installation tasks

To follow idiomatic Provider API practices, many tasks related to compiling and linking native libraries and applications have been converted to use the Provider API.

Tasks extending org.gradle.nativeplatform.tasks.AbstractLinkTask, which include org.gradle.nativeplatform.tasks.LinkExecutable and org.gradle.nativeplatform.tasks.LinkSharedLibrary.

Task type org.gradle.nativeplatform.tasks.CreateStaticLibrary

Task type org.gradle.nativeplatform.tasks.InstallExecutable

Task types org.gradle.language.assembler.tasks.Assemble, org.gradle.language.rc.tasks.WindowsResourceCompile, org.gradle.nativeplatform.tasks.StripSymbols, org.gradle.nativeplatform.tasks.ExtractSymbols, org.gradle.language.swift.tasks.SwiftCompile, and org.gradle.nativeplatform.tasks.LinkMachOBundle were changed in similar ways.

Changes to the Gradle Kotlin DSL

The Gradle Kotlin DSL v0.16 contains several potential breaking changes:

See the release notes for more information.

Removed incubating cache-control DSL in org.gradle.api.artifacts.cache

All interfaces in this package were incubating and there was no public API to obtain instances of any of these interfaces.

Changes to org.gradle.api.reporting.ReportContainer

The following methods were changed:

Immutable systemPropertiesArgs and projectProperties in StartParameter

Now systemPropertiesArgs and projectProperties properties in StartParameter is immutable. This will make any write operation fail, including some unintentional write operation like Groovy's Map.get(Object key, Object defaultValue).

External contributions

We would like to thank the following community members for making contributions to this release of Gradle.

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

Known issues

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