How to clear Gradle cache on Mac

You may need to clear Gradle cache on a Mac after a few years of Android or Java work: the shared cache holds every dependency Gradle has downloaded and often takes several gigabytes. Cleaning a single project doesn’t touch it, and Gradle itself removes only what nobody has used for a while. This guide explains the difference, how to clear the cache safely and how to delete old Gradle versions.

MacWashing, System Junk: Xcode junk, user caches, installers and logs found, 22.83 GB ready to be cleaned
  1. Open MacWashing and choose System Junk in the sidebar.
  2. Click Start Scan.
  3. Look through what it found and click Clean. Anything debatable stays unchecked.

Free trial · macOS 14 or later

What takes space in ~/.gradle

Gradle keeps its shared files in the hidden .gradle folder in your home folder:

  • caches — downloaded dependencies, the build cache and other files Gradle can create or download again. Usually the biggest part.
  • wrapper/dists — the Gradle versions the Gradle Wrapper (gradlew) downloaded for your projects, one folder per version.
  • daemon — logs of the Gradle daemon.

Your own settings live next to them, in gradle.properties and the init.d folder. Leave those in place.

Gradle clean vs the Gradle cache

./gradlew clean deletes the build folder of the project you run it in, with everything Gradle built there. Your sources stay, and the shared cache in ~/.gradle stays too. Run it in the project folder:

./gradlew clean

The next build compiles the project from scratch, so it takes longer. Use it when a build behaves strangely or to free the space of one project.

How to clear Gradle cache

Quit Android Studio or IntelliJ IDEA. Then stop the Gradle daemon, so it doesn’t hold files in the cache open. Run this in any project folder:

./gradlew --stop

If Gradle is installed on its own, gradle --stop does the same. It stops the daemons of that Gradle version only, so if your projects use several versions, run it in a project of each.

  1. In Finder, choose Go › Go to Folder (Shift-Command-G), type ~/.gradle and press Return.
Finder, the ~/.gradle folder: caches selected, next to daemon, native and wrapper
  1. Drag the caches folder to the Trash.
  2. Empty the Trash.

This deletes the downloaded dependencies and build cache of all your projects. Projects, settings and installed tools stay. The next build of each project downloads its dependencies again, so it needs the internet and takes longer.

Delete old Gradle versions

Open ~/.gradle/wrapper/dists. Each folder is one Gradle version, like gradle-8.10-bin. Delete the versions your current projects don’t use. If a project needs a deleted version again, its wrapper downloads it on the next build.

Finder, ~/.gradle/wrapper/dists: one folder per Gradle version, the oldest with «Move to Trash»

Let Gradle clean its cache itself

Gradle removes cache entries nobody used for a while on its own: downloaded files and released Gradle versions after 30 days, the build cache after 7 days. The cleanup runs about once a day, usually in the background when a daemon stops. So the cache stays big mainly when you open many different projects.

Since Gradle 8.0 these periods can be changed with an init script in ~/.gradle/init.d. The Gradle documentation shows how, in its page about the Gradle User Home.

With MacWashing, it’s one click

MacWashing, System Junk: Xcode junk, user caches, installers and logs found, 22.83 GB ready to be cleaned

System Junk in MacWashing lists the Gradle cache under App Caches, left unchecked: downloading the dependencies again takes internet and time, so you decide. Tick it to remove it together with the caches of your other apps and developer tools.

Free trial · macOS 14 or later

Questions and answers

Will MacWashing delete my own files when it cleans?

No. It removes only what it can match to a known app or a known kind of junk, in places apps leave files; macOS and Apple’s files are never touched. Anything debatable is marked and stays unchecked until you decide.

What about apps that are open?

If an open app holds files being cleaned, MacWashing waits for it to quit or quits it at your request, and opens it again afterwards.

Is it free?

Yes, within the free trial: System Junk and the Uninstaller free up to 25 GB in total, with no account or card needed.

Does gradle clean clear the Gradle cache?

No. ./gradlew clean deletes only the build folder of one project. The shared cache in ~/.gradle/caches stays until you delete it or Gradle’s own cleanup removes old entries.

Will clearing the Gradle cache break my projects?

No. Gradle downloads the dependencies again on the next build. Only a build without the internet fails until then, because the files it needs are gone.

Why does the Gradle cache grow back?

Every project brings its own dependencies and often its own Gradle version. Gradle deletes entries unused for 30 days, so the cache shrinks again only when you stop opening old projects.