Maven Cleaner
Safely clean your local Maven repository and Gradle caches — scans for old versions, verifies against Maven Central, protects local-only builds, and reclaims disk space.
Maven Cleaner
A tool to clean up your local Maven repository and Gradle caches. Scans for old artifact versions, checks Maven Central for upstream availability, protects local-only builds, and reclaims disk space safely.
View on GitHub · Latest Release: v0.6.0
Built with Kotlin, JDK 21, and FlatLaf.
What can Maven Cleaner do?
Maven Repository Cleaning
- Scan all versions or snapshots only across your entire
~/.m2/repository - Select Old Versions — automatically identifies all versions except the latest per artifact
- Upstream Verification — checks each artifact against Maven Central before deleting
- Local-Only Protection — artifacts not found upstream are never deleted
- Metadata Refresh — updates
maven-metadata.xmlafter deletion to keep the repository consistent - Latest Version Safety — warns before deleting all versions of an artifact
Gradle Cache Cleaning
- Daemon logs (
.out.logfiles older than 7 days) - Version caches, transform caches, build caches, module caches
- Downloaded Gradle wrapper distributions
- Build scan data and native platform files
Split Repository Migration
Supports the Maven 3.9+ split local repository layout:
~/.m2/repository/cached/— downloaded dependencies (safe to delete)~/.m2/repository/installed/— locally built artifacts (protected)
Detects current layout: Classic, Partially Split, or Fully Split.
How does Maven Cleaner protect against accidental deletion?
- Path validation — refuses to operate outside allowed roots
- Symlink protection — rejects symlinks, validates every walked entry stays within bounds
- TOCTOU mitigation — re-validates paths immediately before each destructive operation
- Bulk trash via JNA — uses Windows
SHFileOperationfor efficient batch Recycle Bin moves - XXE protection on all XML parsers
- Cancel support for all long-running operations
Quick Start
# GUI
.\run-gui.ps1
# CLI — dry run first
.\run-cli.ps1 -DryRun
# CLI — clean without upstream checks (faster, less safe)
.\run-cli.ps1 -SkipUpstream
# CLI — migrate to split repository layout
.\run-cli.ps1 -MigrateSplit -DryRun
.\run-cli.ps1 -MigrateSplit
CLI Flags
| Flag | Description |
|---|---|
--dry-run | Simulate without deleting or moving to trash |
--skip-upstream | Skip Maven Central verification |
--repo <path> | Use a custom repository path |
--migrate-split | Migrate to split repository layout |
Build & Run with Maven
# Build
mvn install -DskipTests
# Launch GUI
mvn -pl swing-ui exec:java -Dexec.mainClass=com.maven.cleaner.ui.MainWindowKt
# Launch CLI
mvn -pl cli exec:java -Dexec.mainClass=com.maven.cleaner.cli.MainKt \
-Dexec.args="--dry-run --skip-upstream"
Requirements
- JDK 21 or higher
- Maven 3.9+
Project Structure
maven-cleaner/
├── core/ Domain models, scanning, cleaning, migration logic
├── cli/ Command-line interface
└── swing-ui/ Swing desktop application (FlatLaf)
FAQ
What is Maven Cleaner?
Maven Cleaner is a desktop tool that scans your local Maven repository (~/.m2/repository) and Gradle caches for old artifact versions, verifies them against Maven Central, and safely reclaims disk space. It is available as a GUI (Swing with FlatLaf) or a command-line interface.
Will Maven Cleaner delete artifacts I built locally?
No. Every artifact is checked against Maven Central before deletion. Artifacts not found upstream — meaning they were built locally and never published — are protected and never deleted.
Does it support Gradle caches?
Yes. It cleans Gradle daemon logs older than 7 days, version caches, transform caches, build caches, module caches, and downloaded Gradle wrapper distributions.
Does Maven Cleaner support the split repository layout?
Yes. It supports the Maven 3.9+ split local repository layout with separate cached/ (downloaded dependencies) and installed/ (locally built) directories. It can also migrate from classic to split layout.
Is there a dry-run mode?
Yes. Run with --dry-run to see what would be deleted without actually removing anything.