Gradle uses two main directories to perform and manage its work: the Gradle User Home directory and the Project Root directory.
Gradle User Home directory
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
.
Not to be confused with the GRADLE_HOME , the optional installation directory for Gradle.
|
It is roughly structured as follows:
├── caches (1)
│ ├── 4.8 (2)
│ ├── 4.9 (2)
│ ├── ⋮
│ ├── jars-3 (3)
│ └── modules-2 (3)
├── daemon (4)
│ ├── ⋮
│ ├── 4.8
│ └── 4.9
├── init.d (5)
│ └── my-setup.gradle
├── jdks (6)
│ ├── ⋮
│ └── jdk-14.0.2+12
├── wrapper
│ └── dists (7)
│ ├── ⋮
│ ├── gradle-4.8-bin
│ ├── gradle-4.9-all
│ └── gradle-4.9-bin
└── gradle.properties (8)
1 | Global cache directory (for everything that is not project-specific). |
2 | Version-specific caches (e.g., to support incremental builds). |
3 | Shared caches (e.g., for artifacts of dependencies). |
4 | Registry and logs of the Gradle Daemon. |
5 | Global initialization scripts. |
6 | JDKs downloaded by the toolchain support. |
7 | Distributions downloaded by the Gradle Wrapper. |
8 | Global Gradle configuration properties. |
Consult the Gradle Directories reference to learn more.
Project Root directory
The project root directory contains all source files from your project.
It also contains files and directories Gradle generates, such as .gradle
and build
, as well as the Gradle configuration directory: gradle
.
gradle and .gradle directories are different.
|
While gradle
is usually checked into source control, build
and .gradle
directories contain the output of your builds, caches, and other transient files Gradle uses to support features like incremental builds.
The anatomy of a typical project root directory looks as follows:
├── .gradle (1)
│ ├── 4.8 (2)
│ ├── 4.9 (2)
│ └── ⋮
├── build (3)
├── gradle
│ └── wrapper (4)
├── gradle.properties (5)
├── gradlew (6)
├── gradlew.bat (6)
├── settings.gradle.kts (7)
├── subproject-one (8)
| └── build.gradle.kts (9)
├── subproject-two (8)
| └── build.gradle.kts (9)
└── ⋮
1 | Project-specific cache directory generated by Gradle. |
2 | Version-specific caches (e.g., to support incremental builds). |
3 | The build directory of this project into which Gradle generates all build artifacts. |
4 | Contains the JAR file and configuration of the Gradle Wrapper. |
5 | Project-specific Gradle configuration properties. |
6 | Scripts for executing builds using the Gradle Wrapper. |
7 | The project’s settings file where the list of subprojects is defined. |
8 | Usually, a project is organized into one or multiple subprojects. |
9 | Each subproject has its own Gradle build script. |
Consult the Gradle Directories reference to learn more.
Next Step: Learn how to structure Multi-Project Builds >>