Clean up project .gradle caches

.gradlenext tobuild.gradlebuild.gradle.ktssettings.gradlesettings.gradle.kts

Quick answer

Yes, a project's .gradle folder is safe to delete when no build is running. Gradle recreates it on the next build. The global ~/.gradle folder is also rebuildable but forces a full re-download.

Rebuild with ./gradlew build

What is it?

A project's .gradle/ holds per-project caches such as file hashes and configuration state. The global ~/.gradle/ holds downloaded dependencies and wrapper distributions for all projects.

Why does it get so big?

  • Per-project file hashes and execution history
  • Caches for each Gradle version used
  • Android projects build many variants

How to clean it from the command line

./gradlew --stop
rm -rf .gradle
./gradlew clean     # build output

Review what a command matches before you run anything with rm -rf. These deletions are permanent.

What not to delete

  • build.gradle(.kts), settings.gradle(.kts) and gradle/wrapper
  • ~/.gradle unless you intend a full re-download

How Gigaflush handles Gradle

Gigaflush lists .gradle only when one of build.gradle, build.gradle.kts, settings.gradle, settings.gradle.kts sits right beside it, shows each folder's size, preselects nothing, and re-checks the folder immediately before deleting it. Symlinks and parent-directory paths are refused.

FAQ

Can I delete the .gradle folder in my project?

Yes, after stopping Gradle daemons. It's regenerated on the next build.

Can I delete ~/.gradle/caches?

Yes, but every project then re-downloads its dependencies. Gigaflush never touches the global cache.

Does gradle clean delete .gradle?

No. ./gradlew clean deletes build output (build/), not the .gradle cache folder.

Further reading