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.
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.
Here are the new features introduced in this Gradle release.
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.
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:
failOnVersionConflict()
no longer fails the dependency insight report in case of conflictThe Gradle Native project continues to improve and evolve the native ecosystem support for Gradle.
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.
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.
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.
The dependency insight report is now considered stable.
Many types and methods that were previously marked @Incubating
are now considered stable.
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.
EclipseProject
tasks defined for gradle eclipse
may now run in BuildshipThe 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.
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 String
s 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.
We would like to thank the following community members for making contributions to this release of Gradle.
ClassCastException
when generating Eclipse files for Gradle (gradle/gradle#5278)EclipseProject
task (eclipse/buildship#694)javadoc
tasks of dependent Java projects (gradle/gradle#5221)UnknownDomainObjectException
instead of NullPointerException
when extension isn't found (gradle/gradle#5547)We love getting contributions from the Gradle community. For information on contributing, please see gradle.org/contribute.
Known issues are problems that were discovered post release that are directly related to changes made in this release.