37

I recently noticed that the .gradle folder in my home directory blew up to a size of almost 2GB. This is mainly caused by the all the old versions located at .gradle/wrapper/dists.

I'm currently running v3.0 so is it necessary to keep all those other binaries and would there be a possible conflict with AndroidStudio which itself runs an internal Gradle wrapper at v2.2.0?

qantik
  • 1,067
  • 1
  • 10
  • 20

2 Answers2

57

You can safely delete the ~/.gradle directory. It is created by the Gradle wrapper to store and cache downloaded files, so it will just repopulate the folder with the files necessary for future builds.

Note that if you made any changes yourself in that directory, you may need to keep those files, such as a ~/.gradle/gradle.properties file.

nhaarman
  • 98,571
  • 55
  • 246
  • 278
  • 3
    @nhaarman What if I don't want to delete all of the caches? I suppose if I delete the entire `~/.gradle`, gradle will re-download all of the necessary files like **distribution files** and **library files**, so it will take a lot of time, especially if we don't have a fast internet connection. I have gradle distributions since 2.1.3 in my current machine, and I want to remove all gradle distributions below 4.0. I think what I need to delete are all files inside `wrapper/dists`, `daemon`, and `caches` where the version is below 4.0. Is that a correct and best approach? Anything that I missed? – HendraWD Sep 17 '18 at 14:23
6

"Periodic cache cleanup" had been added in Gradle 4.10-rc-1 to solve this issue, for details, see: Gradle 4.10-rc-1 release-notes

marc
  • 977
  • 9
  • 14