Chapter 20. The Build Environment

20.1. Configuring the build environment via

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, certain settings like JVM memory settings, Java home, daemon on/off can be more useful if they can versioned with the project in your VCS so that the entire team can work with consistent environment. Setting up a consistent environment for your build is as simple as placing those settings into a file. The configuration is applied in following order (in case an option is configured in multiple locations the last one wins):

  • from located in project build dir.
  • from located in gradle user home.
  • from system properties, e.g. when is used in the command line.

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


When set to true the Gradle daemon is to run the build. For local developer builds this is our favorite property. The developer environment is optimized for speed and feedback so we nearly always run Gradle jobs with the daemon. We don't run CI builds with the daemon (i.e. a long running process) as the CI environment is optimized for consistency and reliability.

Specifies the java home for the Gradle build process. The value can be set to either jdk or jre location, however, depending on what does your build do, jdk is safer. Reasonable default is used if the setting is unspecified.


Specifies the jvmargs used for the daemon process. The setting is particularly useful for tweaking memory settings. At the moment the default settings are pretty generous with regards to memory.


Enables new incubating mode that makes Gradle selective when configuring projects. Only relevant projects are configured which results in faster builds for large multi-projects. See Section, “Configuration on demand”.


When configured, Gradle will run in incubating parallel mode.

20.1.1. Forked java processes

Many settings (like the java version and maximum heap size) can only be specified when launching a new JVM for the build process. This means that Gradle must launch a separate JVM process to execute the build after parsing the various files. When running with the daemon, a JVM with the correct parameters is started once and reused for each daemon build execution. When Gradle is executed without the daemon, then a new JVM must be launched for every build execution, unless the JVM launched by the Gradle start script happens to have the same parameters.

This launching of an extra JVM on every build execution is quite expensive, which is why we highly recommend that you use the Gradle Daemon if you are specifying or org.gradle.jvmargs. See Chapter 19, The Gradle Daemon for more details.

20.2. Accessing the web via a proxy

Configuring an HTTP proxy (for example for downloading dependencies) is done via standard JVM system properties. These properties can be set directly in the build script; for example System.setProperty('http.proxyHost', '') for the proxy host. Alternatively, the properties can be specified in a file, either in the build's root directory or in the Gradle home directory.

Example 20.1. Configuring an HTTP proxy

There are separate settings for HTTPS.

Example 20.2. Configuring an HTTPS proxy

We could not find a good overview for all possible proxy settings. One place to look are the constants in a file from the Ant project. Here a link to the Subversion view. The other is a Networking Properties page from the JDK docs. If anyone knows a better overview, please let us know via the mailing list.

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