Dependency version alignment

This version of Gradle introduces dependency version alignment. This allows different modules belonging to the same logical group (platform) to have identical versions in a dependency graph. Maven BOMs can be imported to define platforms as well.

dependencies {// import a BOM. The versions used in this file will override any other version found in the graph implementation(enforcedPlatform("org.springframework.boot:spring-boot-dependencies:1.5.8.RELEASE"))// define dependencies without versions implementation("com.google.code.gson:gson") implementation("dom4j:dom4j")// this version will be overriden by the one found in the BOM implementation("org.codehaus.groovy:groovy:1.8.6")}

Gradle build initialization features

gradle init functionality has been upgraded in this release: is now optionally interactive, includes new kotlin-library and kotlin-application project types, provides options for configuring project and package names, and more.

Interactive mode

If you run the init task from an interactive console, Gradle will prompt you for details of the Gradle build that you'd like to generate.

Kotlin library and applications

The init task can generate a Kotlin library or application, using the kotlin-library or kotlin-application setup type. This was one of our top 10 most voted issues. To try it out, just run gradle init and follow the prompts.

Generated builds use recommended configurations

The init task generates build scripts that use the recommended implementation, testImplementation, and testRuntimeOnly configurations instead of compile, testCompile, and testRuntime, respectively, for all build setup types.

Configure project and source package names

The init task provides a --project-name option to allow you to adjust the name of the generated project, and a --package option to allow you to adjust the package for the generated source. The task will also prompt you to configure these if you run the task interactively.

Create resource directories

The init task creates empty resource directories.

Create a .gitignore file

While the init task does not automatically create a Git repository, the init task generates a simple .gitignore file to make it easier for you to set up a Git repository. This .gitignore file ignores Gradle's build outputs.

Searchable documentation

Search for Gradle Docs is back. The kind folks at Algolia kindly host an index used to allow you to search the user manual and DSL reference.

Gradle API Javadocs now take advantage of Javadoc built-in autocomplete, making it easier to find classes and methods you're interested in.

Task timeouts

You can now specify a timeout duration for a task, after which it will be interrupted. Read more about task timeouts in the docs.

Performance features

Gradle can be started as a low-priority process

You can now use the --priority low command line argument or org.gradle.priority=low property to start Gradle as a low priority process. This ensures that other applications like your IDE or browser stay responsive, even while a very demanding build is running.

Plural task output properties don't disable caching anymore

When using @OutputFiles or @OutputDirectories with an Iterable type, Gradle used to disable caching for the task with the following message:

This is no longer the case, and using such properties doesn't prevent the task from being cached. The only remaining reason to disable caching for the task is if the output contains file trees.

JaCoCo plugin now works with the build cache and parallel test execution

The JaCoCo plugin plugin now works seamlessly with the build cache. When applying the plugin with no extra configuration, the test task stays cacheable and parallel test execution can be used.

In order to make the tasks cacheable when generating execution data with append = true, the tasks running with code coverage are configured to delete the execution data just before they starts executing. In this way, stale execution data, which would cause non-repeatable task outputs, is removed.

Since Gradle now takes care of removing the execution data, the JacocoPluginExtension.append property has been deprecated. The JaCoCo agent is always configured with append = true, so it can be used when running tests in parallel.

Java 11 runtime support

Java enthusiasts will be happy to read that this release supports running Gradle builds with JDK 11.

Plugin authoring features

This release introduces useful changes for plugin and custom task authors, including an API for creating SourceDirectorySets, improvements to the Provider API, and improved build cache compatibility.

Public method to create SourceDirectorySet instances

The SourceDirectorySet type is often used by plugins to represent some set of source directories and files. Previously, it was only possible to create instances of SourceDirectorySet using internal Gradle types. This is problematic because when a plugin uses internal types it can often break when new versions of Gradle are released because internal types may change in breaking ways between releases.

In this release of Gradle, the ObjectFactory service, which is part of the public API, now includes a method to create SourceDirectorySet instances. Plugins can use this method instead of the internal types.

Provider implementations track their producer task

An important feature of the Provider API is that Provider instances can track both a value and the task or tasks that produces that value. When a Provider that represents an output of a task is connected to a Property instance that represents a task input, Gradle automatically adds task dependencies between the tasks. This eliminates a class of configuration problems where the location of a task input and the producing task dependencies are not kept in sync as configuration changes are made.

In this release, more Provider implementations track the tasks that produces the value of the provider: - Any provider returned by TaskContainer - Any property marked with @OutputFile, @OutputDirectory, @OutputFiles or @OutputDirectories. - Any List or Set property whose elements match these criteria. - Any provider returned by Provider.map() or flatMap() that matches these criteria.

Added Provider.flatMap() method

The flatMap() method allows you to apply a transformation to the values of an existing Provider without realizing the values of that Provider. It returns a new Provider object that is "live" (meaning it will reflect any changes to the values of the original Provider) but will return the transformed values when queried.

Added Property.finalizeValue() method

The property types have a finalizeValue() method which prevents further changes to the value of the property. This is useful in cases where the property needs to be queried and it would be unsafe to then change the value of the property later. After this method as been invoked, calls to methods that change the value of the property (such as set()) will result in an exception.

Task properties are made final before task executes

All task properties that use one of the property types have their value made final when the task executes. This prevents ordering issues where a task property is inadvertently changed after the task executes, resulting in the change having no effect. This will now result in an exception, alerting the user to the unintended error.

Changes to file and directory property construction

ObjectFactory is now used to create file and directory Property instances, similar to other Property types. Previously, this was done using either the methods on DefaultTask, which was available only for DefaultTask subclasses, or using ProjectLayout, only available for projects. Now a single type ObjectFactory can be used to create all property instances in a Gradle model object.

These other methods have been deprecated and will be removed in Gradle 6.0.

Gradle Native features

Promoted features

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.

JavaVersion.VERSION_11 constant along with isJava11() and isJava11Compatible() methods

The --no-rebuild option is no longer deprecated

A change in buildSrc causes the whole project to become out-of-date. Thus, when making small incremental changes, the --no-rebuild command-line option is often helpful to get faster feedback and is therefore no longer deprecated.

Fixed issues

Known issues

Known issues are problems that were discovered post release that are directly related to changes made in this release.

Reporting of TestNG classes/methods

When using a recent version of TestNG (6.9.13.3 or newer), classes were reported to TestListeners as sibling TestDescriptors of test method TestDescriptors. Now, TestDescriptors of classes are parents of their enclosing method TestDescriptors.

Deprecations

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 6.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.

StartParameter properties

The following properties are deprecated and will be removed in Gradle 6.0.

interactive

recompileScripts

Removing tasks from TaskContainer

Removing tasks from the TaskContainer using the following methods has been deprecated and will be an error in Gradle 6.0.

remove(Object)

removeAll(Collection)

retainAll(Collection)

clear()

Iterator#remove() via TaskContainer#iterator()

With the deprecation of every method for removing a task, registering a callback when an object is removed is also deprecated (whenObjectRemoved(Closure/Action)). These methods will be removed in Gradle 6.0

Replacing tasks

It is only safe to replace an unrealized tasks registered with the new Task API because this task has not been used by anything else.

In Gradle 6.0, these behaviors will be treated as errors.

Replacing tasks that may still be used by other tasks

Gradle now emits a deprecation warning when you attempt to replace a task that may have already been used by something else.

Replacing tasks with a task of an incompatible type

Gradle now emits a deprecation warning when you attempt to replace a task with a type that's incompatible from the task being replaced.

Replacing a task that does not exist

Gradle now emits a deprecation warning when you attempt to replace a task that does not already exist.

Removing dependencies from a task

In the next major release (6.0), removing dependencies from a task will become an error.

Gradle will emit a deprecation warning for code such as foo.dependsOn.remove(bar). Removing dependencies in this way is error-prone and relies on the internal implementation details of how different tasks are wired together. At the moment, we are not planning to provide an alternative. In most cases, task dependencies should be expressed via task inputs instead of explicit dependsOn relationships.

The ObjectFactory.property(type), listProperty(type) and setProperty(type) methods no longer set an initial value for the property. Instead, you can use the value() or empty() methods (or any other mutation method) to set an initial value, if required.

Deprecated OSGi plugin

Deprecated code quality plugins

The FindBugs plugin has been deprecated because the project is unmaintained and does not work with bytecode compiled for Java 9 and above. Please consider using the SpotBugs plugin instead.

The JDepend plugin has been deprecated because the project is unmaintained and does not work with bytecode compiled for Java 8 and above.

Resolving configurations in other projects

It is now deprecated behavior to resolve a configuration in another project directly. Projects should interact via project() dependencies declared in configurations of the consuming project. Accessing and resolving configurations in other projects will now produce a deprecation warning.

Resolving configurations from user-managed threads

It is also deprecated behavior to resolve a configuration from a thread that is not managed by Gradle (i.e. a thread created and managed by the user). Threads managed by Gradle (such as the workers that execute tasks) can still resolve configurations safely, but doing so from other threads will now produce a deprecation warning.

Potential breaking changes

Gradle 5.0 requires Java 8

Gradle can no longer be run on Java 7, but requires Java 8 as the minimum build JVM version. However, you can still use forked compilation and testing to build and test software for Java 6 and above.

Tooling API and TestKit require Gradle 2.6 or higher

The Tooling API can no longer connect to builds using a Gradle version below Gradle 2.6. The same applies to builds run through TestKit.

Tooling API clients before 3.0 are now longer supported

Gradle 5.0 requires a minimum Tooling API client version of 3.0. Older client libraries can no longer run builds with Gradle 5.0

Lower default memory settings

The command line client now starts with 64m of heap instead of 1g. This may affect builds running directly inside the client VM using --no-daemon mode. We discourage the use of --no-daemon, but if you must use it, you can increase the available memory using the GRADLE_OPTS environment variable.

The Gradle daemon now starts with 512m of heap instead of 1g. Metaspace is now limited to 256m. It was unlimited before. Large projects may have to increase this setting using the org.gradle.jvmargs property.

All workers, including compilers and test executors, now start with 512m of heap. The previous default was 1/4th of physical memory. Large projects may have to increase this setting on the relevant tasks, e.g. JavaCompile or Test.

Fixes to dependency resolution

Dependency resolutions fixes have been included in this release. By definition this could impact the set of resolved dependencies of your build. However the fixed issues are mostly about corner cases and combination with recent features and thus should have a limited impact.

When a dependency constraint matched a real dependency, it was made part of the graph. However if for some reason the dependency was later evicted from the graph, the constraint remained present. Now when the last non-constraint edge to a dependency disappears, all constraints for that dependency will be properly removed from the graph.

When converting this to use the new API, something surprising happens: bar doesn't exist. The new API only executes configuration actions when necessary, so the register() for task bar only executes when foo is configured.

tasks.register("foo") { tasks.register("bar") // WRONG }

To avoid this, Gradle now detects this and prevents modification to the underlying container (through create or register) when using the new API.

Removed support for Play Framework 2.2

JaCoCo plugin deletes execution data on task execution

Checkstyle plugin config directory in multi-project builds

Gradle will now, by convention, only look for Checkstyle configuration files in the root project's config/checkstyle directory. Checkstyle configuration files in subprojects — the old by-convention location — will be ignored unless you explicitly configure their path via checkstyle.configDir or checkstyle.config.

maven plugin now publishes Maven 3 metadata

The maven plugin used to publish the highly outdated Maven 2 metadata format. This has been changed and it will now publish Maven 3 metadata, just like the maven-publish plugin.

Updated default tool versions

The default tool versions of the following code quality plugins have been updated:

The Checkstyle plugin now uses 8.12 instead of 6.19 by default.

The CodeNarc plugin now uses 1.2.1 instead of 1.1 by default.

The JaCoCo plugin now uses 0.8.2 instead of 0.8.1 by default.

The PMD plugin now uses 6.8.0 instead of 5.6.1 by default. In addition, the default ruleset was changed from the now deprecated java-basic to category/java/errorprone.xml. We recommend configuring a ruleset explicitly, though.

Library upgrades

Several libraries that are used by Gradle have been upgraded:

Groovy was upgraded from 2.4.15 to 2.5.2 (see http://groovy-lang.org/releasenotes/groovy-2.5.html about the changes in this release).

Ant has been upgraded from 1.9.11 to 1.9.13.

The AWS SDK used to access S3 backed Maven/Ivy repositories has been upgraded from 1.11.267 to 1.11.407.

The BND library used by the OSGi plugin has been upgraded from 3.4.0 to 4.0.0.

The JUnit Platform libraries used by the Test task have been upgraded from 1.0.3 to 1.3.1.

The Maven Wagon libraries used to access Maven repositories have been upgraded from 2.4 to 3.0.0.

SLF4J has been upgraded from 1.7.16 to 1.7.25.

Gradle now bundles JAXB for Java 9 and above

In order to use S3 backed artifact repositories, it was previously required to add --add-modules java.xml.bind to org.gradle.jvmargs when running on Java 9 and above. Since Java 11 no longer contains the java.xml.bind module, Gradle now bundles JAXB 2.3.1 (com.sun.xml.bind:jaxb-impl) and uses it on Java 9 and above. Please remove the --add-modules java.xml.bind option from org.gradle.jvmargs, if set.

CopySpec.duplicatesStrategy is no longer nullable

For better compatibility with the Kotlin DSL, the property setter no longer accepts null as a way to reset the property back to its default value. Use DuplicatesStrategy.INHERIT instead.

For easier configurability from statically compiled languages such as Java or Kotlin.

Javadoc and Groovydoc delete destination dir

The Javadoc and Groovydoc tasks now delete the destination dir for the documentation before executing. This has been added to remove stale output files from the last task execution.

Changes to property factory methods on DefaultTask

Property factory methods on DefaultTask are final

The property factory methods such as newInputFile() are intended to be called from the constructor of a type that extends DefaultTask. These methods are now final to avoid subclasses overriding these methods and using state that is not initialized.

Inputs and outputs are not automatically registered

The Property instances that are returned by these methods are no longer automatically registered as inputs or outputs of the task. The Property instances need to be declared as inputs or outputs in the usual ways, such as attaching annotations such as @OutputFile or using the runtime API to register the property.

Source and test source dirs in IdeaModule no longer contain resources

The IdeaModule Tooling API model element contains methods to retrieve resources and test resources so those elements were removed from the result of IdeaModule#getSourceDirs() and IdeaModule#getTestSourceDirs().

Source task source field access

In previous Gradle versions the source filed in SourceTask was accessible from subclasses. This is not the case anymore as the source filed is now declared as private.

The left shift operator on the Task interface is no longer supported

The left shift (<<) operator acted as an alias for adding a doLast action to an existing task. It was deprecated since Gradle 3.2 and has now been removed.

Invalid project and domain object names are no longer supported

Previously, it was deprecated for project and domain object names to be empty, start or end with . or contain any of the following characters: /\:<>"?*|. The use of such names now causes the build to fail.

Evaluation of the publishing {} block is now eager

In Gradle 4.8, the old behavior of the publishing {} block to defer its evaluation was deprecated. A new behavior that made its evaluation eager (like for any other block) was introduced and switched on using enableFeaturePreview('STABLE_PUBLISHING'). Now, the old behavior has been removed and switching on the new one is no longer necessary. If you need to defer evaluation, please use afterEvaluate {}.

Annotation processors on the compile classpath are now ignored

Annotation processors on the compile classpath are no longer detected and used when compiling Java projects. This might cause compilation errors when upgrading to Gradle 5.0. Please add annotation processors to the annotation processor path instead.

MavenDeployer#uniqueSnapshot has been removed

With the removal of Maven 2 support, the methods to configure unique snapshot behavior have been removed. Maven 3 only supports unique snapshots, so these methods would have had no more effect. We decided to remove them instead of leaving a deprecated no-op in place.

Changes to previously deprecated APIs

Removed the methods getToSignArtifact and setFile from Signature.

Removed the property targetSizeInMB from DirectoryBuildCache.

Removed the methods dependsOnTaskDidWork and deleteAllActions from Task.

Removed the ability to cast (Groovy as) FileCollection to File[] and File.

Removed the method getBuildDependencies from AbstractFileCollection.

Removed the methods file and files from TaskDestroyables.

Removed the property styleSheet from ScalaDocOptions.

Removed the methods newFileVar and newDirectoryVar from ProjectLayout.

Removed the method property from ProviderFactory.

Removed the method property from Project.

Removed the method property from Script.

Removed the method leftShift from Task.

Removed the type RegularFileVar.

Removed the type DirectoryVar.

Removed the type PropertyState.

Removed the method configureForSourceSet from JavaBasePlugin.

Removed the property classesDir from JDepend.

Removed the property testClassesDir from Test.

Removed the property classesDir from SourceSetOutput.

Removed the methods performPostEvaluationActions from IdeaPlugin and EclipsePlugin.

Removed the method setDestination(Object) from ConfigurableReport.

Removed the internal @Option and @OptionValues annotations from the org.gradle.api.internal.tasks.options package.

Removed the @DeferredConfigurable annotation.

Removed the method isDeferredConfigurable from ExtensionSchema

Forbid passing null as configuration action to the methods from and to on CopySpec.

Removed the property bootClasspath from CompileOptions.

Validation problems for inputs or outputs registered via the runtime API now fail the build.

Chaining calls to the methods file, files, and dir on TaskInputs is now impossible.

Chaining calls to the methods file, files, and dir on TaskOutputs is now impossible.

Chaining calls to the method property and properties on TaskInputs is now an error.

JavaPluginConvention is now abstract.

ApplicationPluginConvention is now abstract.

WarPluginConvention is now abstract.

EarPluginConvention is now abstract.

BasePluginConvention is now abstract.

ProjectReportsPluginConvention is now abstract.

Removal of deprecated CLI options

Removed --no-search-upward (-u) option.

Removed --recompile-scripts option.

Implicit imports for internal classes have been removed

Classes in the internal org.gradle.util package are no longer implicitly imported by default. Please either stop using internal classes (recommended) or import them explicitly at the top of your build file.

Removed system properties

The test.single filter mechanism has been removed. You must select tests from the command-line with --tests.

The test.debug mechanism to enable debugging of JVM tests from the command-line has been removed. You must use --debug-jvm to enable debugging of test execution.

The org.gradle.readLoggingConfigFile system property no longer does anything — please update affected tests to work with your java.util.logging settings.

Replacing built-in tasks

In earlier versions of Gradle, builds were allowed to replace tasks that may be automatically created. This was deprecated in Gradle 4.8 and has now been turned into an error.

Attempting to replace a built-in task will produce an error similar to the following:

Changes to internal APIs

Gradle TestKit will search upwards for settings.gradle

When invoking a build, Gradle TestKit now behaves like a regular Gradle invocation, and will search upwards for a settings.gradle file that defines the build. Please ensure that all builds being executed with Gradle TestKit define settings.gradle, even if this is an empty file.

Cannot specify --source-path directly as a Java compiler arg

Adding -sourcepath or --source-path to the CompileOptions.compilerArgs list is now prohibited. The source path for a JavaCompile task should be set via the CompileOptions.sourcePath property.

Cannot specify --processor-path directly as a Java compiler arg

Adding -processorpath or --processor-path to the CompileOptions.compilerArgs list is now prohibited. Annotation processors should instead be added to the annotationProcessor configuration.

Worker API: working directory of a worker can no longer be set

Since JDK 11 no longer supports changing the working directory of a running process, setting the working directory of a worker via its fork options is now prohibited. All workers now use the same working directory to enable reuse. Please pass files and directories as arguments instead.