misonoteApp Center

Maven ~/.m2/repository taking up space: can you delete it?

Check before deletingMay still be useful; Thermo moves it to the Trash by default, so you can change your mind.

Where it is

  • ~/.m2/repository

What it is

Maven downloads every dependency and plugin your builds need into the local repository at ~/.m2/repository, laid out by group, artifact and version. Running Maven's install phase also writes your own built artifacts there, and other JVM build tools can read from it.

Why it gets so big

Maven never removes old versions on its own, and snapshot dependencies can pile up many timestamped copies. Years of projects mean years of JARs.

Is it safe to delete?

Mostly. Anything downloaded from a remote repository comes back on the next build. It's flagged for review because it can also contain artifacts you installed locally or JARs added by hand, which no server can give back; projects depending on them won't build until you rebuild or reinstall them. Your settings.xml lives in ~/.m2 itself and isn't affected.

Tip

To trim rather than wipe, delete only the group folders for libraries and projects you no longer work with.

See how much space it uses

du -sh "$HOME/.m2/repository" 2>/dev/null

Delete it by hand

Run in Terminal. Deleting cannot be undone, so check the paths first.

rm -rf "$HOME/.m2/repository"/*