Gradle Directories
Gradle has 3 main directories:
- Gradle Home
- Gradle User Home
- Project Root
1. Gradle Home
Gradle Home is the Gradle installation directory. It is common to set the environment variable GRADLE_HOME
for this directory. Its structure like this:
├─bin/
| ├─gradle
| └─gradle.bat
├─init.d/
| └─readme.txt
└─lib/
| ├─agents/
| └─plugins/
├─LICENSE
├─NOTICE
└─README
You can add .gradle (e.g. test.gradle) init scripts to the directory init.d
. Each one is executed at the start of the build.
2. Gradle User Home
By default, the Gradle User Home (~/.gradle
or C:\Users\<USERNAME>\.gradle
) stores global configuration properties, initialization scripts, caches, and log files.
It can be set with the environment variable GRADLE_USER_HOME
. It is roughly structured as follows:
├── caches
│ ├── 4.8
│ ├── 4.9
│ ├── ⋮
│ ├── jars-3
│ └── modules-2
├── daemon
│ ├── ⋮
│ ├── 4.8
│ └── 4.9
├── init.d
│ └── my-setup.gradle
├── jdks
│ ├── ⋮
│ └── jdk-14.0.2+12
├── wrapper
│ └── dists
│ ├── ⋮
│ ├── gradle-4.8-bin
│ ├── gradle-4.9-all
│ └── gradle-4.9-bin
└── gradle.properties
You can add .gradle (e.g. test.gradle) init scripts to the directory init.d
. Each one is executed at the start of the build. For example:
my-setup.gradle
allprojects {
repositories {
maven {
name 'Aliyun'
url 'https://maven.aliyun.com/repository/public'
}
}
}
3. Project Root
The project root directory contains all source files from your project.
It also contains files and directories Gradle generates, such as .gradle and build.
While gradle is usually checked into source control, the build directory contains the output of your builds as well as transient files Gradle uses to support features like incremental builds.
The anatomy of a typical project root directory looks as follows:
├── .gradle/
│ ├── 4.8/
│ ├── 4.9/
│ └── ⋮
├── gradle/
│ └── wrapper/
├── gradlew
├── gradlew.bat
├── gradle.properties
├── buildSrc/
| └── build.gradle
├── subproject-one/
| └── build.gradle
├── subproject-two/
| └── build.gradle
├── settings.gradle
├── build/
├── .gitignore
├── .gitattributes
└── ⋮