Interested in configuring your Build Cache to speed up builds? Register here for our Build Cache training session to learn some of the tips and tricks top engineering teams are using to increase build speed.

Gradle provides multiple mechanisms for configuring behavior of Gradle itself and specific projects. The following is a reference for using these mechanisms.

When configuring Gradle behavior you can use these methods, listed in order of highest to lowest precedence (first one wins):

  • Command-line flags such as --build-cache. These have precedence over properties and environment variables.

  • System properties such as stored in a file.

  • Gradle properties such as org.gradle.caching=true that are typically stored in a file in a project root directory or GRADLE_USER_HOME environment variable.

  • Environment variables such as GRADLE_OPTS sourced by the environment that executes Gradle.

Aside from configuring the build environment, you can configure a given project build using Project properties such as -PreleaseType=final.

Gradle properties

Gradle provides several options that make it easy to configure the Java process that will be used to execute your build. While it’s possible to configure these in your local environment via GRADLE_OPTS or JAVA_OPTS, it is useful to be able to store certain settings like JVM memory configuration and Java home location in version control so that an entire team can work with a consistent environment. To do so, place these settings into a file committed to your version control system.

The final configuration taken into account by Gradle is a combination of all Gradle properties set on the command line and your files. If an option is configured in multiple locations, the first one found in any of these locations wins:

  • command line, as set using the -P / --project-prop environment options.

  • in GRADLE_USER_HOME directory.

  • in project root directory.

  • in Gradle installation directory.

Note that the location of the Gradle user home may have been changed beforehand via the -Dgradle.user.home system property passed on the command line.

The following properties can be used to configure the Gradle build environment:


When set to true, Gradle will reuse task outputs from any previous build, when possible, resulting in much faster builds. Learn more about using the build cache. By default, the build cache is not enabled.


When set to true, individual input property hashes and the build cache key for each task are logged on the console. Learn more about task output caching. Default is false.


Enables incubating configuration on demand, where Gradle will attempt to configure only necessary projects. Default is false.


Customize console output coloring or verbosity. Default depends on how Gradle is invoked. See command-line logging for additional details.

org.gradle.continuous.quietperiod=(# of quiet period millis)

When using continuous build, Gradle will wait for the quiet period to pass before triggering another build. Any additional changes within this quiet period restart waiting for the quiet period. Default is 250 milliseconds.


When set to true the Gradle Daemon is used to run the build. Default is true, builds will be run using the daemon.

org.gradle.daemon.idletimeout=(# of idle millis)

Gradle Daemon will terminate itself after specified number of idle milliseconds. Default is 10800000 (3 hours).


When set to true, Gradle will run the build with remote debugging enabled, listening on port 5005. Note that this is the equivalent of adding -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 to the JVM command line and will suspend the virtual machine until a debugger is attached. Default is false.

org.gradle.debug.port=(port number)

Specifies the port number to listen on when debug is enabled. Default is 5005.


If set to true and debugging is enabled, Gradle will run the build with the socket-attach mode of the debugger. Otherwise, the socket-listen mode is used. Default is true.


When set to true and debugging is enabled, the JVM running Gradle will suspend until a debugger is attached. Default is true. to JDK home)

Specifies the Java home for the Gradle build process. The value can be set to either a jdk or jre location, however, depending on what your build does, using a JDK is safer. This does not affect the version of Java used to launch the Gradle client VM (see Environment variables). A reasonable default is derived from your environment (JAVA_HOME or the path to java) if the setting is unspecified.

org.gradle.jvmargs=(JVM arguments)

Specifies the JVM arguments used for the Gradle Daemon. The setting is particularly useful for configuring JVM memory settings for build performance. This does not affect the JVM settings for the Gradle client VM. The default is -Xmx512m "-XX:MaxMetaspaceSize=256m".


When set to quiet, warn, lifecycle, info, or debug, Gradle will use this log level. The values are not case sensitive. See Choosing a log level. The lifecycle level is the default.


When configured, Gradle will fork up to org.gradle.workers.max JVMs to execute projects in parallel. To learn more about parallel task execution, see the section on Gradle build performance. Default is false.


Specifies the scheduling priority for the Gradle daemon and all processes launched by it. See also performance command-line options. Default is normal.


Configures verbose logging when watching the file system. Default is false.,false)

Toggles watching the file system. When enabled Gradle re-uses information it collects about the file system between builds. Enabled by default on operating systems where Gradle supports this feature.


When set to all, summary or none, Gradle will use different warning type display. See Command-line logging options for details. Default is summary.

org.gradle.workers.max=(max # of worker processes)

When configured, Gradle will use a maximum of the given number of workers. See also performance command-line options. Default is number of CPU processors.


Specifies whether stacktraces should be displayed as part of the build result upon an exception. See also the --stacktrace command-line option. When set to internal, a stacktrace is present in the output only in case of internal exceptions. When set to all or full, a stacktrace is present in the output for all exceptions and build failures. Using full doesn’t truncate the stacktrace, which leads to a much more verbose output. Default is internal.


Controls whether Gradle should print a welcome message. If set to never then the welcome message will be suppressed. If set to once then the message is printed once for each new version of Gradle. Default is once.

The following example demonstrates usage of various properties.

Example 1. Setting properties with a file
tasks.register('printProps') {
    doLast {
        println commandLineProjectProp
        println gradlePropertiesProp
        println systemProjectProp
// Project properties can be accessed via delegation
val commandLineProjectProp: String by project
val gradlePropertiesProp: String by project
val systemProjectProp: String by project

tasks.register("printProps") {
    doLast {
$ gradle -q -PcommandLineProjectProp=commandLineProjectPropValue -Dorg.gradle.project.systemProjectProp=systemPropertyValue printProps

System properties

Using the -D command-line option, you can pass a system property to the JVM which runs Gradle. The -D option of the gradle command has the same effect as the -D option of the java command.

You can also set system properties in files with the prefix systemProp.

Specifying system properties in

The following system properties are available. Note that command-line options take precedence over system properties.


Specify user name to download Gradle distributions from servers using HTTP Basic Authentication. Learn more in Authenticated wrapper downloads.


Specify password for downloading a Gradle distribution using the Gradle wrapper.

gradle.user.home=(path to directory)

Specify the Gradle user home directory.


Specify the supported TLS versions in a comma separated format. For example: TLSv1.2,TLSv1.3.

In a multi project build, “systemProp.” properties set in any project except the root will be ignored. That is, only the root project’s file will be checked for properties that begin with the “systemProp.” prefix.

Environment variables

The following environment variables are available for the gradle command. Note that command-line options and system properties take precedence over environment variables.


Specifies JVM arguments to use when starting the Gradle client VM. The client VM only handles command line input/output, so it is rare that one would need to change its VM options. The actual build is run by the Gradle daemon, which is not affected by this environment variable.


Specifies the Gradle user home directory (which defaults to $USER_HOME/.gradle if not set).


Specifies the JDK installation directory to use for the client VM. This VM is also used for the daemon, unless a different one is specified in a Gradle properties file with

Project properties

You can add properties directly to your Project object via the -P command line option.

Gradle can also set project properties when it sees specially-named system properties or environment variables. If the environment variable name looks like ORG_GRADLE_PROJECT_prop=somevalue, then Gradle will set a prop property on your project object, with the value of somevalue. Gradle also supports this for system properties, but with a different naming pattern, which looks like org.gradle.project.prop. Both of the following will set the foo property on your Project object to "bar".

Setting a project property via a system property
Setting a project property via an environment variable

The properties file in the user’s home directory has precedence over property files in the project directories.

This feature is very useful when you don’t have admin rights to a continuous integration server and you need to set property values that should not be easily visible. Since you cannot use the -P option in that scenario, nor change the system-level configuration files, the correct strategy is to change the configuration of your continuous integration build job, adding an environment variable setting that matches an expected pattern. This won’t be visible to normal users on the system.

You can access a project property in your build script simply by using its name as you would use a variable.

If a project property is referenced but does not exist, an exception will be thrown and the build will fail.

You should check for existence of optional project properties before you access them using the Project.hasProperty(java.lang.String) method.

Configuring JVM memory

You can adjust JVM options for Gradle in the following ways:

The org.gradle.jvmargs Gradle property controls the VM running the build. It defaults to -Xmx512m "-XX:MaxMetaspaceSize=256m"

Changing JVM settings for the build VM
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

The JAVA_OPTS environment variable controls the command line client, which is only used to display console output. It defaults to -Xmx64m

Changing JVM settings for the client VM
JAVA_OPTS="-Xmx64m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8"

There is one case where the client VM can also serve as the build VM: If you deactivate the Gradle Daemon and the client VM has the same settings as required for the build VM, the client VM will run the build directly. Otherwise the client VM will fork a new VM to run the actual build in order to honor the different settings.

Certain tasks, like the test task, also fork additional JVM processes. You can configure these through the tasks themselves. They all use -Xmx512m by default.

Example 2. Set Java compile options for JavaCompile tasks
plugins {
    id 'java'

tasks.withType(JavaCompile) {
    options.compilerArgs += ['-Xdoclint:none', '-Xlint:none', '-nowarn']
plugins {

tasks.withType<JavaCompile>().configureEach {
    options.compilerArgs = listOf("-Xdoclint:none", "-Xlint:none", "-nowarn")

See other examples in the Test API documentation and test execution in the Java plugin reference.

Build scans will tell you information about the JVM that executed the build when you use the --scan option.

Build Environment in build scan

Configuring a task using project properties

It’s possible to change the behavior of a task based on project properties specified at invocation time.

Suppose you’d like to ensure release builds are only triggered by CI. A simple way to handle this is through an isCI project property.

Example 3. Prevent releasing outside of CI
tasks.register('performRelease') {
    doLast {
        if (project.hasProperty("isCI")) {
            println("Performing release actions")
        } else {
            throw new InvalidUserDataException("Cannot perform release outside of CI")
tasks.register("performRelease") {
    doLast {
        if (project.hasProperty("isCI")) {
            println("Performing release actions")
        } else {
            throw InvalidUserDataException("Cannot perform release outside of CI")
$ gradle performRelease -PisCI=true --quiet
Performing release actions

Accessing the web through a proxy

Configuring a proxy (for downloading dependencies, for example) is done via standard JVM system properties. These properties can be set directly in the build script; for example, setting the HTTP proxy host would be done with System.setProperty('http.proxyHost', ''). Alternatively, the properties can be specified in

Configuring an HTTP proxy using

There are separate settings for HTTPS.

Configuring an HTTPS proxy using
# NOTE: this is not a typo.

There are separate settings for SOCKS.

Configuring a SOCKS proxy using

You may need to set other properties to access other networks. Here are 2 references that may be helpful:

NTLM Authentication

If your proxy requires NTLM authentication, you may need to provide the authentication domain as well as the username and password. There are 2 ways that you can provide the domain for authenticating to a NTLM proxy:

  • Set the http.proxyUser system property to a value like domain/username.

  • Provide the authentication domain via the http.auth.ntlm.domain system property.