Gradle Release Notes

Version 4.9

The Gradle team is pleased to announce Gradle 4.9.

First, publishing tools get some more love: projects that publish auxiliary publications (e.g. test fixtures) through maven-publish and ivy-publish can now be depended upon by other projects in the same build. There is also a new Publishing Overview chapter in the user manual and updates throughout the documentation regarding publishing artifacts using Maven and Ivy.

On to the Kotlin DSL, which reaches version 0.18.4 included in this distribution of Gradle. In addition to quicker .gradle.kts evaluation and other UX improvements, we're delighted to introduce a new guide: Migrating build logic from Groovy to Kotlin. This covers considerations and build script snippets that are essential to a successful migration. You will start seeing more and more Groovy and Kotlin side-by-side in the documentation — stay tuned!

Next up, you can now pass arguments to JavaExec tasks directly from the command-line using --args:

❯ gradle run --args 'foo --bar'

No more need to hard-code arguments in your build scripts. Consult the documentation for the Application Plugin for more information.

Last but not least, this version of Gradle has an improved dependency insight report. Read the details further on.

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

Table Of Contents

Upgrade Instructions

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

./gradlew wrapper --gradle-version=4.9

Standalone downloads are available at gradle.org/install.

New and noteworthy

Here are the new features introduced in this Gradle release.

Command line args supported by JavaExec

Command line arguments can be passed to JavaExec with --args. For example, if you want to launch the application with command line arguments foo --bar, you don't need to hardcode it into the build script - you can just run gradle run --args 'foo --bar'. See the Application Plugin documentation for more information.

Improved dependency insight report

The dependency insight report is the distant ancestor of build scans and helps you diagnose dependency management problems locally. This release of Gradle implements several improvements:

Continuing development of Native ecosystem

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

Faster clean checkout builds

Gradle now stores more state in the Gradle user home instead of the project directory. Clean checkout builds on CI should now be faster as long as the user home is preserved.

Java and Groovy compiler no longer leak file descriptors

The Java and Groovy compilers both used to leak file descriptors when run in-process (which is the default). This could lead to "cannot delete file" exceptions on Windows and "too many open file descriptors" on Unix. These leaks have been fixed. If you had switched to forking mode because of this problem, it is now safe to switch back to in-process compilation.

Experimental new task API

In a nutshell, the new task API allows builds to avoid the cost of creating and configuring tasks when those tasks will never be executed.

Some Gradle tasks have converted to use this API, so you may see slightly faster configuration times just by upgrading. The benefits will improve as more plugins adopt this API.

To learn more about the lazy task API, please refer to the Task Configuration Avoidance chapter covering migration, try it out in non-production environments, and file issues or discuss with us. Your feedback is very welcome. This API is incubating and may change in breaking ways before Gradle 5.0.

For more insight regarding the performance goals refer to the blog post introducing how those new lazy task APIs can improve your configuration time.

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.

Dependency insight report

The dependency insight report is now considered stable.

Tooling API types and methods

Many types and methods that were previously marked @Incubating are now considered stable.

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.

Potential breaking changes

EclipseProject tasks defined for gradle eclipse may now run in Buildship

The EclipseClasspath and EclipseProject tasks both accept beforeMerged and whenMerged closures, for advanced Eclipse-specific customisation.

Previous versions of Gradle did not execute the closures defined in EclipseProject when invoked from Buildship (only those in EclipseClasspath). Now Gradle executes them both, similarly to when invoked from the command-line.

This leads to a potential change of behavior in this scenario: - These closures were defined for use with gradle eclipse - The gradle project was later imported into Eclipse, but these definitions were not removed.

The code in these closures will now become active in the Gradle -> Refresh Gradle Project action.

Using Groovy GPath with tasks.withType()

In previous versions of Gradle, it was sometimes possible to use a GPath expression with a project's task collection to build a list of a single property for all tasks.

For instance, tasks.withType(SomeTask).name would create a list of Strings containing all of the names of tasks of type SomeTask. This was only possible with the method TaskCollection.withType(Class).

Plugins or build scripts attempting to do this will now get a runtime exception. The easiest fix is to explicitly use the spread operator.

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.