Gradle 6.1 adds relocatable dependency cache and a few more changes
Gradle is an invaluable tool for helping teams build, automate, and effectively deliver software. The latest version is out. Version 6.1 adds a few goodies, fixes some bugs, and adds some improvements for plugin authors and tooling providers. See what’s included in this update and how to upgrade your build and keep up with the new releases.
Gradle version 6.0 released in November 2019. Now, welcome the newest build of 2020: Gradle version 6.1.
Let’s see what the newest version of this built-automation system adds. View the release notes for the complete rundown and full list of changes.
With the new release, you can configure dependencies between JVM languages, all in one project. This affects the relationship between Java, Groovy, and Scala compilation.
From the release notes:
These task dependencies have been remodelled using directory properties. The relationship between compilation tasks is expressed in the task’s classpath. Removing a directory property from the classpath also removes the corresponding task dependency. This can be used to change the relationship between Java, Groovy and Scala compilation tasks.
The dependency cache can now also be relocated, from The Gradle Dependency cache under
$GRADLE_HOME/caches/modules-2 to another directory or host for directories cached by Gradle 6.1
Learn Gradle with new samples
New to Gradle and need some help getting started? The update adds a new index of downloadable samples that show off what you can build using Gradle. For instance, learn how to build an Android app, a Groovy library, a Java library, a Spring Boot web application, a Kotlin library, and more.
All sample downloads include a Gradle wrapper and explore some common problems that you may encounter.
While not as hefty as version 6.0 was, 6.1 introduces a few miscellaneous updates worth looking at. It now supports compiling Groovy code and includes support for method parameter names with JDK 8 or newer.
Plugin authors will be happy to know that 6.1 includes improvements that will help their work, including new managed property types, and a few new factory methods.
That’s not all
Besides the 6.1 release, on January 13, 2020 Gradle introduced a new plugin that will end flaky tests. Test Retry Gradle Plugin augments the built-in test tasks and retries any tests that have failed until either it reaches the maximum number of retries, or no failing tests remain.
There are 4 especially neat aspects to this plugin:
- No test source changes are required. This allows proactive detection of new flaky tests!
- You can control whether your build fails or passes when flakiness is encountered using
failOnPassedAfterRetry. This means that you can adopt this plugin to detect flaky tests without silencing them.
- You can prevent retrying in a test run after a discrete number of tests fail using
maxFailures. If your build encounters many failures, it’s likely there is a major problem causing many tests to fail and retrying is a waste of resources.
- Tests are retried at method-level or finer where possible — no rerunning whole classes of tests!
This plugin runs with Gradle v5.0 and newer, so you can upgrade to the latest version and test out the plug-in.
Have you upgraded to Gradle 6.0 yet? Be sure to review the guide for upgrading your build from Gradle 5.x to 6.0. For those already migrated to 6.x, the user guide for upgrading to the latest release is available here.
Update your wrapper by using:
./gradlew wrapper --gradle-version=6.1