Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are there numbers in Gradle cache directories?

Tags:

java

gradle

A downloaded dependency, e.g. log4j is cached in the Gradle user home directory like ~/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j.

But why modules-2 and files-2.1 instead of modules and files?

It doesn't look like the version of Gradle. For instance, there is no "6" or "6.0" while I'm using Gradle 6.0 on my PC.

~/.gradle/caches/jars-1
~/.gradle/caches/jars-2
~/.gradle/caches/jars-3
~/.gradle/caches/modules-2
~/.gradle/caches/modules-2/files-2.1
~/.gradle/caches/transforms-1
~/.gradle/caches/transforms-2
like image 640
NVXARM Avatar asked Nov 27 '19 05:11

NVXARM


People also ask

What is Gradle cache directory?

The local build cache uses a system directory to store tasks outputs. The default location is the Gradle user home directory that points to $USER_HOME/. gradle/caches. Every time we run the build in our system, artifacts will be stored here.

How do I clean up .Gradle folder?

Clear your project directoryClear the cache of Android Studio using “File -> Invalidate Caches / Restart” choose “Invalidate and restart option” and close Android Studio. Remove your . gradle directory from the root of your project. It contains some Gradle cache files.

What is in the .Gradle folder?

gradle folder inside your home directory. It consist of native (information about your system) and caches. Caches further consist of plugins and all other jars dependencies.


1 Answers

The numbers refer to different layouts needed by different versions of gradle. Whenever there is a breaking change in the cache layout in a new version of gradle these numbers will be incremented.

If a new version of gradle still uses the same cache layout as the previous one, these numbers don't get incremented. Thus the new version can use the already existing caches without wasting disk space.

For example the number of the modules, files and metadata directory changed with this commit for a layout change introduced with gradle 1.9

https://github.com/gradle/gradle/commit/aace47c2e5f8d137fadc6b07baf84371efb48c09

like image 165
dpr Avatar answered Oct 20 '22 15:10

dpr