I was quite surprised that I couldn't find this anywhere, but anyways, I would like to know the purpose of each folder in the .gradle
folder, and how safe it is to delete them, especially in terms of portability.
caches
folder, since it contains the
downloaded dependencies. daemon
folder seems to only contain
logs?workers
is apparently empty for mewrapper
seems irrelevant, since I don't use gradle wrapper. Why does it even download all those wrappers?native
.Directory layout is described in "The Directories and Files Gradle Uses" chapter of its user guide.
├── 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
├── wrapper
│ └── dists // <6>
│ ├── ⋮
│ ├── gradle-4.8-bin
│ ├── gradle-4.9-all
│ └── gradle-4.9-bin
└── gradle.properties // <7>
From version 4.10 onwards, Gradle automatically cleans its user home directory. The cleanup runs in the background when the Gradle daemon is stopped or shuts down. If using --no-daemon
, it runs in the foreground after the build session with a visual progress indicator.
The following cleanup strategies are applied periodically (at most every 24 hours):
caches/<gradle-version>/
are checked for whether they are still in use. If not, directories for release versions are deleted after 30 days of inactivity, snapshot versions after 7 days of inactivity.caches/
(e.g. jars-*
) are checked for whether they are still in use. If there's no Gradle version that still uses them, they are deleted.caches/
(e.g. jars-3
or modules-2
) are checked for when they were last accessed. Depending on whether the file can be recreated locally or would have to be downloaded from a remote repository again, it will be deleted after 7 or 30 days of not being accessed, respectively.wrapper/dists/
are checked for whether they are still in use, i.e. whether there's a corresponding version-specific cache directory. Unused distributions are deleted.native
seem to contain platform-specific dependencies (like .so
, .dll
) for libraries like Jansi: it needs them to provide rich console output (like colours in the output). The code for that features is not documented, but you can take a look here. Particularly library.jansi.path
system property points to ~/.gradle/native/jansi/1.17.1/linux64
(on my machine; you can check that by printing System.getProperties()
in a custom Gradle task).
workers
seems to be used as a working directory for the workers described in Workers API.
wrappers
could be downloaded by the IDE. Basically, if you have this directory non-empty that means that you've actually used a wrapper at least once.