Skip to content
← All Mac folders

Mac folder guide

~/.m2 Folder on Mac: Is It Safe to Delete?

~/.m2/repository

~/.m2 is Maven’s folder in your home folder, and ~/.m2/repository is the local copy of every dependency Maven has downloaded. The repository is safe to delete. Keep settings.xml, which holds your configuration.

Partly saferepository is safe to clear, settings.xml is not

What is ~/.m2/repository on a Mac?

Maven, and tools that reuse its repository, cache every jar and pom they download here, in folders that mirror the group and artifact names.

Old versions are never removed automatically, so it grows for as long as you build Java projects.

What’s inside

  • repository, the downloaded dependencies
  • settings.xml, your Maven settings, if you created one

How to clear ~/.m2/repository safely

  1. Check the size with the first command below.
  2. Delete the repository folder, or just the group folders you know are old.
  3. Run a build. Maven downloads what the project needs.
Check (read only)
du -sh ~/.m2/repository
Clear (deletes the local repository)
rm -rf ~/.m2/repository

When to keep it

  • settings.xml, which can hold mirrors and credentials
  • Artifacts you built and installed locally with mvn install that exist nowhere else

Questions people ask

Is it safe to delete the .m2 folder?+

Delete ~/.m2/repository freely. Keep ~/.m2/settings.xml, which holds your configuration.

What happens after I delete the Maven repository?+

The next build downloads every dependency again, so it is slower and needs a connection.

Does Gradle use ~/.m2?+

Gradle keeps its own cache in ~/.gradle, though some builds also read the local Maven repository.

See which folders fill your Mac

MacZentra, a disk analyzer and storage cleaner for Mac, scans your disk locally and draws it as a Treemap or Sunburst, so a folder like this one shows up with its real size. Scanning and every visualization are free. Cleaning is a one-time $49.99 purchase, and anything you remove goes to the Trash, so it can be restored.

macOS 13 Ventura or later · Apple silicon