What’s new in Gradle 5.2

The Java and Android build tool adds offers plugin enhancements for Java and C++

What’s new in Gradle 5.2
Vudhikul Ocharoen / Getty Images

Gradle 5.2, the latest version of the Java and Android build tool, offers plugin enhancements for Java and C++.

Where to download Gradle

You can download Gradle from Gradle.org.

Current release: The new features in Grade 5.2

Gradle 5.2 includes a Java Platform Plugin for declaring platforms for the Java ecosystem. A platform could include a set of modules published together that could, for example, be of the same version. It also could be a set of recommended versions of heterogeneous libraries, or the sharing of a set of dependency versions between subprojects. Platforms can be published as Maven bills of materials or with the experimental Gradle metadata file format.

Other new features in the latest Gradle release include:

  • New C++ plugins that rely on a domain-specific language (DSL) and configuration model. When the plugin is applied to the project, Gradle registers an extension for the type of project, be it an application or library. Configuration is done through this extension or tasks registered by the plugin. The plugins support C++ libraries and applications on Windows, Linux, and MacOS.
  • Incremental and parallel compilation is supported, along with cachable compilation using Gradle’s build cache. Dependency management is available, similar to Java projects built with Gradle.
  • Gradle 5.2 has new project types for gradle_init.
  • Service injection into plugins and project extensions, in which services can be injected into the elements of a container built using the container(Class) method. This can simplify plugin implementation. Services can be injected into an instance as constructor parameters or using a property getter method, for types in which service injection is available.
  • Gradle Kotlin DSL 1.1.3, which provides bug fixes and Kotlin 3.20.

Previous version: New features in Gradle 5.1

Version 5.1 of the Gradle build tool for Java and Android development has arrived, with capabilities for dependency matching and configuration-avoidance APIs.

Released in January 2019, the upgrade enables matching of repositories to dependencies. With this capability, Gradle will not search for a dependency in a repository if it is not there. For configuration avoidance, meanwhile, a new API for creating and configuring Task instances allows Gradle to avoid creating tasks that do not need to be executed. The Gradle team recommends that developers use this API when working with tasks in plug-ins.

Other new features in Gradle 5.1 include:

  • Gradle Kotlin DSL 1.1, bringing Kotlin 1.3.11 support for Kotlin lambdas in Gradle APIs as well as fixes and enhancements to improve behavior in IntelliJ IDE script dependency resolution.
  • A capability for targeting multiple architectures when building C++ projects using the targetMachines property.
  • Improvements for plug-in authors, including stricter validation with validateTaskProperties and conveniences for Map properties.
  • To make it easier to find tasks in builds with many available tasks, gradle tasks now can only show tasks belonging to a particular group.
  • Tooling API types reported as part of ProgressEvents to registered ProgressListeners gain some enhancements. For example, TaskOperatorDescriptor now includes the identifier of the plug-in registering the task and its dependencies.

Previous version: New features in Gradle 5.0

Gradle 5.0, released in November 2018, offers the Kotlin Version 1.0 domain-specific language (DSL), Java 11 support, and dependency version alignment.

Gradle 5.0 provides an editing experience for Kotlin in its supported IDEs: JetBrains’s IntelliJ Idea and Google’s Android Studio. The DSL will make it easier to write build logic using the Kotlin language, with improved completion, error highlighting, and refactoring tools.

Version 5.0 adds support for running builds with Java Development Kit 11, the latest production version of Java SE.

Dependency version alignment lets different modules in the same group have identical versions in a dependency graph. Maven bills of materials can be imported to define platforms as well.

Other new features in Gradle 5.0 include:

  • Task timeouts, through which developers can specify a duration for a task, after which it will be interrupted.
  • Gradle can be started as a low-priority process, to ensure that other applications, such as the IDE or browser, stay responsive even when a demanding build is running.
  • The JaCoCo plugin, providing code coverage metrics for Java code integration, works with the build cache. When applying this plugin without extra configuration, the test task stays cacheable; parallel test execution can be used.
  • For writing plugins, an API has been added for creating SourceDirectorySet. Also, improvements have been made to the Provider API and to build cache compatibility. More Provider implementations track tasks that produce the value of the provider.
  • There are 159 fixes in Gradle 5.0, addressing issues such as missing include paths for MacOS frameworks to one in which the schema from named domain object containers changed during execution, exposing internal types.
  • Among deprecations, the interactive and recompileScripts properties have been deprecated and will be removed in Gradle 6.0.
  • Java 8 is required as the minimum build JVM version, although tests can be run using Java 6 or Java 7. Developers still can use forked compilation and testing to build and test software for Java 6 and later. Also, the command line client now starts with 64MB of heap instead of 1GB, which could affect builds running directly inside the VM using –no-daemon mode.

Copyright © 2019 IDG Communications, Inc.