Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Gradle 6 Brings Significant Dependency Management Improvements

Gradle 6 Brings Significant Dependency Management Improvements

This item in japanese

Gradle, the customizable open source build automation tool, has released version 6.0 with significant improvements to dependency management, out of the box support for javadoc and source jars, and faster incremental compilation of Java and Groovy code. In addition, the latest release 6.1.1 supports a relocatable dependency cache for speeding up ephemeral CI builds.

Gradle’s dependency management saw a number of improvements in version 6. The documentation has been restructured to help users find information on commonly used terminology, and use cases related to dependency management.

Gradle Module Metadata, a format similar to Apache Maven’s POM file, is now published by default when using Maven or ivy based publish plugins. Based on this module metadata, Gradle can recommend and share versions between projects called platforms, a set of modules aimed to be used together.

Gradle’s new component capabilities can be used to detect and resolve conflicts between mutually exclusive dependencies. A capability identifies a feature, like logging, offered by one or more modules or libraries. By using capabilities, Gradle’s dependency management engine can detect incompatible capabilities in a dependency graph, and allow users to choose when different modules in a dependency graph provide the same capability.

For example, say a module depends on SLF4J API library and Apache ZooKeeper library and wants to use the JDK logging as the SLF4J implementation library. Since ZooKeeper itself depends on Log4J as the SLF4J implementation library, the module might end up with two SLF4J implementations on its classpath. By declaring a component capability rule that states that both JDK logger and Log4J libraries provide the same capability, Gradle can preemptively detect the conflict.

In addition, Gradle provides the concept of dependency constraints to pick the highest version of a transitive dependency that satisfies all declared constraints.

Gradle 6 supports automatic creation and publishing of javadoc jars and source code jars. It also publishes the information about these jars using Gradle Module Metadata. This feature can be activated for a Java or Java library project:

java {

Gradle 6 provides faster incremental compilation of Java and Groovy code by analyzing the impact of code changes and excluding classes that are an implementation detail of another class from recompilation. Gradle skips recompiling classes in different projects using the compilation avoidance feature. For large projects with multiple modules and deep dependency chains, this enhancement will reduce the number of recompilations and speed up incremental compilation.

Starting with version 6.1, Gradle’s dependency cache can be copied and made available to an ephemeral build agent in order for the agent to reuse the previously downloaded dependencies, and speed up the build process. An ephemeral build agent is an agent that is used just once and discarded at the end of a build. Since ephemeral agents have no state, each build will need to download dependencies from remote repositories. By copying an existing dependency cache to ephemeral build agents, builds will no longer pay the cost of downloading all dependencies.

Some of the other noteworthy features in Gradle 6 are support for JDK 13, security improvements to protect build integrity, ability to define compilation order between languages in polyglot JVM builds, and improvements for Gradle plugin authors and tooling providers.

Rate this Article