This reference guide describes the various types which make up the Gradle build language, or DSL.
There are a few basic concepts that you should understand, which will help you write Gradle scripts.
First, Gradle scripts are configuration scripts. As the script executes, it
configures an object of a particular type. For example, as a build script executes, it configures an
object of type
Project. This object is called the delegate object
of the script. The following table shows the delegate for each type of Gradle script.
The properties and methods of the delegate object are available for you to use in the script.
Second, each Gradle script implements the
Script interface. This
interface defines a number of properties and methods which you can use in the script.
A build script is made up of zero or more statements and script blocks. Statements can include method calls, property assignments, and local variable definitions. A script block is a method call which takes a closure as a parameter. The closure is treated as a configuration closure which configures some delegate object as it executes. The top level script blocks are listed below.
Configures this project and each of its sub-projects.
Configures the published artifacts for this project.
Configures the build script classpath for this project.
Configures the dependency configurations for this project.
Configures the dependencies for this project.
Configures the repositories for this project.
Configures the source sets of this project.
Configures the sub-projects of this project.
A build script is also a Groovy script, and so can contain those elements allowed in a Groovy script, such as method definitions and class definitions.
Listed below are some of the central types which are used in Gradle scripts:
This interface is the main API you use to interact with Gradle from your build file. From a
Represents an invocation of Gradle.
Declares the configuration required to instantiate and configure the hierarchy of
A build that is included in the composite.
This interface is implemented by all Gradle Groovy DSL scripts to add in some Gradle-specific methods. As your compiled script class will implement this interface, you can use the methods and properties declared by this interface directly in your script.
Provides access to any input files that need to be processed by an incremental task.
Defines the strategies around dependency resolution. For example, forcing certain dependency versions, substitutions, conflict resolutions or snapshot timeouts.
A builder to construct a query that can resolve selected software artifacts of the specified components.
Represents a tuple of the component selector of a module and a candidate version to be evaluated in a component selection rule.
Represents a container for component selection rules. Rules can be applied as part of the resolutionStrategy of a configuration and individual components can be explicitly accepted or rejected by rule. Components that are neither accepted or rejected will be subject to the default version matching strategies.
Objects that can be extended at runtime with other objects.
Additional, ad-hoc, properties for Gradle domain objects.
The DSL for declaring plugins to use in a script.
A mutable specification of a dependency on a plugin.
Configures how plugins are resolved.
Provides access to resource-specific utility methods, for example factory methods that create various resources.
Provides access to any input files that need to be processed by an incremental work action.
A distribution allows to bundle an application or a library including dependencies, sources...
Listed below are the types used to configure publishing:
The configuration of how to “publish” the different components of a project.
An artifact published as part of a
A Collection of
The descriptor of any Ivy publication.
An author of an Ivy publication.
A license of an Ivy publication.
The description of an Ivy publication.
An artifact published as part of a
A Collection of
The POM for a Maven publication.
The CI management system of a Maven publication.
A contributor of a Maven publication.
Allows to add contributors of a Maven publication.
A developer of a Maven publication.
Allows to add developers to a Maven publication.
The distribution management configuration of a Maven publication.
The issue management system of a Maven publication.
A license of a Maven publication.
Allows to add licenses to a Maven publication.
A mailing list of a Maven publication.
Allows to add mailing lists to a Maven publication.
The organization of a Maven publication.
The relocation information of a Maven publication that has been moved to a new group and/or artifact ID.
The SCM (source control management) of a Maven publication.
Container types that handle various declarative elements (e.g. dependencies, configurations, artifacts, tasks, etc.):
Allows the build to provide rules that modify the metadata of depended-on software components.
Component metadata rules are applied in the components section of the dependencies block
This class is for defining artifacts to be published and adding them to configurations. Creating publish artifacts does not mean to create an archive. What is created is a domain object which represents a file to be published and information on how it should be published (e.g. the name).
Credentials and Authentication types for connecting to repositories:
An artifact repository which supports username/password authentication.
Base interface for credentials used for different authentication purposes.
A username/password credentials that can be used to login to password-protected remote repository.
Represents credentials used to authenticate with Amazon Web Services.
Credentials that can be used to login to a protected server, e.g. a remote repository by using HTTP header.
Container for configuring repository authentication schemes of type
Base interface for transport authentication schemes.
Authentication scheme for basic access authentication over HTTP. When using this scheme, credentials are sent preemptively.
Authentication scheme for HTTP header authentication over HTTP.
Authentication scheme for digest access authentication over HTTP.
Types used to connect to and configure the build cache:
Types used to configure input normalization
Used to configure input normalization. Currently, it is only possible to configure runtime classpath normalization.
Input normalization configuration. Input normalization is used when Gradle tries to determine if two task inputs are different. Gradle normalizes both inputs and the inputs are considered different if and only if the normalizations are different.
Configuration of runtime classpath normalization.
Below are the task types that are available for every Gradle project. Those task types can also be declared and configured directly in the build script.
Displays a list of tasks in the project. An instance of this type is used when you execute the
Displays a list of projects in the build. An instance of this type is used when you execute the
Displays the dependency tree for a project. An instance of this type is used when you
Generates a report that attempts to answer questions like:
Displays the properties of a project. An instance of this type is used when you execute the
Displays some details about the software components produced by the project.
Displays dependent components.
Displays some details about the configuration model of the project.
An instance of this type is used when you execute the
Listed below are the various task types which are available for use in your build script:
Generates parsers from Antlr grammars.
Provides information about the build environment for the project that the task is associated with.
Runs Checkstyle against some source files.
Runs CodeNarc against some source files.
Copies files into a destination directory. This task can also rename and filter files as it copies. The task
Creates start scripts for launching JVM applications.
Deletes files or directories. Example:
Assembles an EAR archive.
Executes a command line process. Example:
Generates an Ivy XML Module Descriptor file.
Generates a Maven module descriptor (POM) file.
Generates build dashboard report.
Executes a Gradle build.
Compiles Groovy source files, and optionally, Java source files.
Generates HTML API documentation for Groovy source, and optionally, Java source.
Generates an HTML dependency report. This report combines the features of the ASCII dependency report and those of the ASCII dependency insight report. For a given project, it generates a tree of the dependencies of every configuration, and each dependency can be clicked to show the insight of this dependency.
Task to generate HTML, Xml and CSV reports of Jacoco coverage data.
Task to merge multiple execution data files into one.
Task for verifying code coverage metrics. Fails the task if violations are detected based on specified rules.
Assembles a JAR archive.
Compiles Java source files.
Generates HTML API documentation for Java classes.
Executes a Java application in a child process.
Runs a set of static code analysis rules on Java source code files and generates a report of problems found.
Publishes an IvyPublication to an IvyArtifactRepository.
Compiles Scala source files, and optionally, Java source files.
Generates HTML API documentation for Scala source files.
Generates a Gradle project structure.
A task for creating digital signature files for one or more; tasks, files, publishable artifacts or configurations.
Synchronizes the contents of a destination directory with some source directories and files.
Assembles a TAR archive.
Abstract class for all test task.
Executes JUnit (3.8.x, 4.x or 5.x) or TestNG tests. Test are always run in (one or more) separate JVMs.
Generates an HTML test report from the results of one or more
Uploads the artifacts of a
Assembles a WAR archive.
Generates scripts (for *nix and windows) which allow you to build your project with Gradle, without having to install Gradle.
Assembles a ZIP archive. The default is to compress the contents of the zip.
Listed below are some of the types which are used when generating reports:
A HTML Report whose generation can be customized with a XSLT stylesheet.
A report that is a single file.
A directory based report to be created.
A file based report to be created.
An object that provides reporting options.
A container of
A project extension named "reporting" that provides basic reporting settings and utilities.
Used to configure Eclipse or IDEA plugins
DSL-friendly model of the Eclipse project information. First point of entry for customizing Eclipse project generation.
Enables fine-tuning project details (.project file) of the Eclipse plugin
The build path settings for the generated Eclipse project. Used by the
Enables fine-tuning jdt details of the Eclipse plugin
Enables fine-tuning wtp/wst details of the Eclipse plugin
Enables fine-tuning wtp component details of the Eclipse plugin
Enables fine-tuning wtp facet details of the Eclipse plugin
DSL-friendly model of the IDEA project information. First point of entry when it comes to customizing the IDEA generation.
Enables fine-tuning project details (*.ipr file) of the IDEA plugin.
Enables fine-tuning module details (*.iml file) of the IDEA plugin.
Enables fine-tuning workspace details (*.iws file) of the IDEA plugin.
Models the generation/parsing/merging capabilities. Adds XML-related hooks.
Models the generation/parsing/merging capabilities.
Tasks contributed by IDE plugins. To configure IDE plugins please use IDE model types.
Generates an Eclipse
Generates an Eclipse
Generates the Eclipse JDT configuration file. If you want to fine tune the eclipse configuration
Generates the org.eclipse.wst.common.component settings file for Eclipse WTP. If you want to fine tune the eclipse configuration
Generates the org.eclipse.wst.common.project.facet.core settings file for Eclipse WTP. If you want to fine tune the eclipse configuration
Generates an IDEA module file. If you want to fine tune the idea configuration
Generates an IDEA project file for root project *only*. If you want to fine tune the idea configuration
Generates an IDEA workspace file *only* for root project. There's little you can configure about workspace generation at the moment.
Tasks contributed by Xcode IDE plugins. To configure IDE plugins please use IDE model types.
Task for generating a Xcode scheme file (e.g.
Task for generating a Xcode workspace settings file (e.g.
Task for generating a Xcode project file (e.g.
Task for generating a Xcode workspace file (e.g.
Tasks contributed by Visual Studio IDE plugins. To configure IDE plugins please use IDE model types.
Used to define artifact transforms.
Used to configure tool chains for building C++ and Swift components.
Used to configure software components developed with native code.
A library component that is not built by gradle.
A shared library that exists at a known location on the filesystem.
A static library that exists at a known location on the filesystem.
Definition of a software component that is to be built by Gradle to run a on JVM platform.
Definition of a native executable component that is to be built by Gradle.
Definition of a native library component that is to be built by Gradle.
A component representing a suite of tests that will be executed together.
Test suite of CUnit tests.
Test suite of Google Test tests.
Represents a binary artifact that is the result of building a native component.
An binary built by Gradle for a native application.
Represents a binary artifact that is the result of building a native library component.
A shared library binary built by Gradle for a native library.
A static library binary built by Gradle for a native library.
An executable which runs a suite of tests.
An executable which run a CUnit test suite.
An executable which run a Google Test test suite.
Specifies a build-type for a native binary. Common build types are 'debug' and 'release', but others may be defined.
Defines a custom variant that differentiate a
A set of assembly language sources.
A set of C source files.
A set of C++ source files.
A set of Objective-C source files.
A set of Objective-C++ source files.
A set of Windows Resource definition files.
A visual studio project, created from one or more native binaries.
A visual studio solution, representing one or more native binaries in a build.
An executable native component that is built by Gradle.
A library component that is built by a gradle project.
Represents a particular binary artifact.
A binary artifact for a
Used to configure C++ components.
Configuration for a C++ application, defining the source files that make up the application plus other settings.
Configuration for a C++ library, defining the source files and header directories that make up the library plus other settings.
A C++ test suite.
Used to configure Swift components.
Configuration for a Swift application, defining the source files that make up the application plus other settings.
Configuration for a Swift library, defining the source files that make up the library plus other settings.
A XCTest suite, implemented in Swift.
Tasks used to build native binaries.
Compiles C++ source files into object files.
Compiles Swift source files into object files.
Links a binary executable from object files and libraries.
Links a binary shared library from object files and imported libraries.
Assembles a static library from object files.
Links a binary bundle from object files and imported libraries.
Installs an executable with it's dependent libraries so it can be easily executed.
Creates a XCTest bundle with a run script so it can be easily executed.
Runs a compiled and installed test executable.
Executes XCTest tests. Test are always run in a single execution.
Tasks used to build native binaries.
Compiles C source files into object files.
Translates Assembly language source files into object files.
Compiles Objective-C source files into object files.
Compiles Objective-C++ source files into object files.
Compiles Windows Resource scripts into .res files.