days
-7
-2
hours
-2
0
minutes
-5
-4
seconds
-5
-9
search
What's new and noteworthy

Java enthusiasts rejoice! Gradle 4.7 adds JDK 10 support

Gabriela Motroc
Gradle

© Shutterstock /Steve Bower

Gradle 4.7 is here and it brings a lot of exciting new features, including support for resources and test resources in the IDEA plugin; running Gradle builds with JDK 10 is also possible. Let’s have a look at the highlights.

All things Java! There are a lot of exciting features in Gradle 4.7 but let’s start with the most important one, namely JDK 10 support.

Before we dive into the details of Gradle 4.7, perhaps you’d like to see a summary of what’s new and noteworthy:

Gradle 4.7: What’s new and noteworthy

Gradle’s incremental Java compiler can now run annotation processing incrementally, according to the release notes. This means that user-facing configuration isn’t necessary, but processor authors need to opt-in. Make sure you read the documentation for this feature before you give it a try.

You’ll be happy to know that interleaved logs are officially a thing of the past on CI since Gradle log output is now grouped by task for non-interactive executions. It also enables build scan plugin v1.13 to show logs per task:

Source: Gradle 4.7 Release Notes

Running tests has also been improved as failed tests now run first. Together with the --fail-fast option it offers the fastest possible feedback loop.

Gradle 4.7 also introduces an incubating new capability for Kotlin DSL users, namely precompiled script plugins. You can now create a Kotlin DSL script within a regular Kotlin source set and get the benefits of binary plugins.

SEE ALSO: Build Gradle projects with Eclipse Buildship

Speaking of Kotlin DSL, v0.16 also includes Kotlin 1.2.31, which is a more consistent API, better IDE support, and more. Find out more about it in the Kotlin DSL v0.16 release notes.

As far as the IDEA plugin is concerned, it now automatically marks your Java resource directories (e.g. src/main/resources) as resources in the IDEA project hierarchy. You can also 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')
    }
}

Deprecations

The following features have been deprecated in Gradle 4.7:

Task.deleteAllActions() is deprecated without replacement.

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

It’s no longer possible to cast a FileCollection instance to some special types using the Groovy as keyword — it has been discontinued.

  • the FileCollection.asType(Class) method is deprecated
  • casting fileCollection as File is deprecated, use FileCollection.getSingleFile() instead
  • casting fileCollection as File[] is deprecated
  • casting fileCollection as FileTree is deprecated, use FileCollection.getAsFileTree() instead

However, using the as operator to cast FileCollection to Object[]CollectionSet and List is still supported.

For more information about Gradle 4.7, see the release notes.

To use Gradle 4.7, you’ll have to update your wrapper properties:

gradle wrapper --gradle-version=4.7

Standalone downloads are available here.

Author
Gabriela Motroc
Gabriela Motroc is editor of JAXenter.com and JAX Magazine. Before working at Software & Support Media Group, she studied International Communication Management at the Hague University of Applied Sciences.