Part of: Mac disk cleanup for developers: every cache, what it costs to rebuild (Developers)
You can clear identified Gradle cache data by quitting anything that uses Gradle and selecting caches, unused wrapper/dists entries or daemon logs inside ~/.gradle. Keep gradle.properties, init.gradle(.kts), init.d and any other user configuration. Cleared caches make the next build slower and may require downloads.
Gradle is the build tool behind most Android projects and many Java and Kotlin ones. It keeps a lot in one hidden folder in your home directory.
See what is there first
Run this in Terminal to see the size of each part:
du -sh ~/.gradle/*
On the Mac used to check this article, the biggest parts were caches, jdks and wrapper, and the daemon logs were smaller. Yours will differ with the number of projects and Gradle versions you use. If you want to look around, open ~/.gradle shows the folder in Finder.
What each part is
caches: downloaded libraries and the results of earlier builds. It is usually the largest part.wrapper/dists: a full copy of each Gradle version your projects ask for. The wrapper is a small script in a project that downloads the right Gradle version for it.daemon: logs from the background Gradle process, called the daemon, that keeps builds quick between runs.jdks: Java runtimes that Gradle downloaded for your builds.
Safe, risky, never
- Safe:
daemonlogs, andwrapper/distsentries for Gradle versions you no longer use. Cost: a project that needs an old version downloads it again. - Risky:
caches. Cost: every dependency of every project downloads again. That can be many gigabytes and a long first build. If you work offline or on a metered connection, wait until you are online. - Never:
gradle.properties,init.gradle(.kts),init.dor any other user configuration. These can contain your settings and build scripts, not disposable cache data. Keep them.
See Gradle-managed directories and caches for the documented layout and automatic cache maintenance.
How to clear it
- Quit Android Studio, IntelliJ and any terminal running a build, so no Gradle process holds the files. A Gradle daemon can keep running after the IDE closes, so check Activity Monitor for
javaprocesses if you are unsure. - Select only identified cache data from the list above. Start with unused
wrapper/distsentries anddaemonlogs. Preserve all settings and init scripts; do not remove the entire~/.gradlefolder. - Move those folders to the Trash in Finder, then empty the Trash. The space comes back only when you empty it, as the Trash article explains.
- Open a project and build it. Gradle recreates what it needs.
Removing a single project’s .gradle folder, the one that sits next to its build files, is a smaller and safer step. It holds build state for that project only.
Keep builds fast after clearing
A cold cache makes the first build slow. You can soften it:
- Clear the parts one at a time instead of everything, and rebuild your main project first.
- Leave
cachesalone for the projects you work on every day, and remove only ones you have finished with. A single large cache shared by active projects is the point of the cache. - Do not clear it right before a deadline or a train ride.
Does it overlap with Android Studio and Maven?
A little. Android Studio keeps its own emulator images and SDK files outside .gradle, so clearing Gradle does not touch them. See Android Studio taking up too much space for those. Maven, another Java build tool, has its own cache in ~/.m2. See where the .m2 folder is. The two do not share files, so clearing one does not shrink the other.
The full list of developer folders and what each costs to rebuild is in the developer cleanup guide.
Worked example: which Gradle versions do you keep?
The wrapper/dists folder has one subfolder per Gradle version. List them with a read-only command:
ls ~/.gradle/wrapper/dists
It lists one folder per Gradle version your projects have used. Each version is a full copy of Gradle. If your projects use only the newest, the others are what you can remove first. To learn which version a project wants, open its gradle/wrapper/gradle-wrapper.properties file. The version is in the distributionUrl line.
Check all your active projects before you remove one. A project you forgot will download the version again, which is a small cost.
The home folder is one place, projects are another
~/.gradle is shared by every project. Each project can also have a .gradle folder of its own, next to its build files, and a build folder with output. Removing a build folder is the usual way to get a fresh build. It is separate from the shared cache, and cheaper to rebuild.
On the same Mac, the ~/.gradle folder also had jdks, native and workers. If you see folders not in the list above, leave them. They come from Gradle or its plugins.
If something goes wrong
- A build says it cannot find a dependency. You may be offline, or the library is no longer at its source. Reconnect and try again.
- A project downloads a Gradle version again. You removed it from
wrapper/dists. That is expected. - The build says a Java version is missing. Gradle downloaded it into
jdksand you removed it. The next build can fetch it again if your project allows that. - Builds are slow for days. You may have cleared
cachesfor projects you use often. Rebuild the main ones first.
When not to clean
Do not clear caches if you will be on a plane or a slow network soon. Do not touch gradle.properties in any cleanup. It holds your settings.
Check the size with DiskJoy
DiskJoy is our product. Its scan reads your disk and shows how large ~/.gradle and other developer folders are, without changing anything. Cleanup is not built yet, so DiskJoy does not delete these folders for you today.
Quick checklist
- Run
du -sh ~/.gradle/*and see which part is large. - Quit your IDE and builds.
- Remove
daemonlogs and oldwrapper/distsfirst. - Remove
cachesonly if you can afford a full re-download. - Empty the Trash and run a build.
Frequently asked questions
Is it safe to delete the .gradle folder?
Do not delete the entire folder. Remove only identified cache data such as caches, unused wrapper/dists entries or daemon logs. Preserve gradle.properties, init.gradle(.kts), init.d and any other user configuration. Cleared caches require a slow rebuild and may need downloads before offline builds work again.
Where is the Gradle cache on Mac?
By default in a hidden folder named .gradle in your home folder, with the downloaded dependencies in .gradle/caches. A project can also have its own .gradle folder next to its build files, which holds build state for that project.
Will deleting it break my project?
Removing identified cache data leaves project source and build files intact, but deleting user configuration can break builds. Preserve your settings and init scripts. The next build runs slower while Gradle recreates caches and downloads missing dependencies or wrapper files.