-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
The current gradle target in mac-cache-cleaner only reports the size of ~/.gradle/caches and ~/.gradle/wrapper/dists but has no cleanup commands. Unlike other tools (npm, pip, cargo), Gradle doesn't provide a native CLI command to clean its global cache.
Proposed Solution
Create a cleanup mechanism that:
- Creates a temporary minimal Gradle project with a wrapper
- Runs
./gradlew --no-daemonwhich performs cleanup when it completes - Removes the temporary project directory
This approach leverages Gradle's built-in behavior where running with --no-daemon ensures cleanup happens when the JVM exits, avoiding orphaned daemon processes and their associated cache locks.
Implementation Details
- Create a temp directory with minimal
build.gradle.ktsorbuild.gradle - Include
settings.gradle.ktswith project name - Run
gradle wrapperto generate gradlew (or include pre-generated wrapper files) - Execute
./gradlew --no-daemon cleanor a custom cleanup task - Clean up the temporary directory
Current State
{Name: "gradle", Enabled: true, Notes: "Gradle build caches and wrappers",
Paths: []string{"~/.gradle/caches", "~/.gradle/wrapper/dists"},
Cmds: [][]string{}, // <-- No cleanup commands
Tools: []Tool{{Name: "gradle", InstallCmd: "brew install gradle"}}},Considerations
- Requires Gradle or Java to be installed
- Should handle cases where Gradle is not available gracefully
- May need to stop running Gradle daemons first (
gradle --stop) - Consider which cache directories are safe to clean:
~/.gradle/caches/build-cache-*- Build cache (safe)~/.gradle/caches/transforms-*- Transform cache (safe)~/.gradle/caches/modules-*- Dependency cache (will re-download)~/.gradle/wrapper/dists/- Downloaded Gradle distributions
Alternatives Considered
- Direct
rm -rf ~/.gradle/caches/- Works but violates "safety first" principle of using official CLI commands - Gradle cache cleanup plugin - Requires modifying user's Gradle setup
gradle --stoponly - Frees memory but not disk space
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request