SoFunction
Updated on 2025-04-10

Comprehensive tutorial on setting Gradle attributes and environment variables

Gradle property (Gradle build environment)

[Details]("/current/userguide/build_environment.html#sec:gradle_configuration_properties")

The gradle attribute can be set in the following places, according to priority level

  • Use -=value when building

  • GRADLE_USER_HOME directory

  • project properties in the file under the root directory

  • Properties in files under gradle installation directory

Below are the available gradle properties

  • =(true,false)

    Whether to use cache when building

  • =(true,false)

    Whether Log debug information

  • =(true,false)

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

  • =(auto,plain,rich,verbose)

    console color

  • =(true,false)

    Whether the gradle build process can be utilized, default true, can speed up Build

  • =(# of idle millis)

    The Gradle daemon will terminate itself after the specified number of free milliseconds. The default value is 10800000 (3 hours).

  • =(true,false)

    Whether to debug gradle, this will add parameters to jvm run-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005

  • =(path to JDK home)

    Specify the jdk path

  • jvm attributes that need to be added

  • =(quiet,warn,lifecycle,info,debug)

    gradle log level

System environment variables

[See here for details]('/current/userguide/build_environment.html#sec:gradle_environment_variables')

JAVA_HOME

gradle directory to use,

GRADLE_USER_HOME

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

Specify a gradle user home, if not specified, it will be in the .gradle folder in the current system user directory. This directory will be stored in different versions of gradle and gradle library files.

GRADLE_OPTS

Specify the jvm parameter when running gradle

System variables

At this time, the system variable refers to the system variable in java, and also contains the variable -=value. This variable can be obtained through [Details]

("/current/userguide/build_environment.html#sec:gradle_system_properties")

These system variables are best placed in the root directory of the project, otherwise they may not work

  • If authentication is required during download, set the user name
  • If authentication is required during download, this property sets the user password
  • Function Same Environment variable GRALE_USER_HOME

These variables can also be written in files, but when multi-projects are built, except for the root directory, other subprojects will be ignored, and the format is like this

=myuser
=mypassword

Project properties

Only work for this project

Attributes in the user directory will take precedence over project properties

In the project's file

# Set the value of the attribute foo to bar=bar

It can also be configured through environment variables

ORG\_GRADLE\_PROJECT_foo=bar

Meaning is to set the value of an engineering variable ```foo``` to ``bar``

Set up the network proxy used by gradle

http

=
=8080
=userid
=password
=*.|localhost

https

=
=8080
=userid
=password
=*.|localhost

The above is the detailed content of the comprehensive tutorial on setting Gradle attributes and environment variables. For more information about setting environment variables in Gradle attributes, please pay attention to my other related articles!