Where apps hide your files
Maven keeps every library it downloads in a hidden .m2 folder in your home directory. You can open it, see what is taking the space, and point Maven at a different location.
~/.m2/repository (the local repository: downloaded jars and poms)
~/.m2/settings.xml (your user settings, if you have created one)
Both are the defaults in Maven's own settings documentation: the local repository is ${user.home}/.m2/repository, and the user settings file is ${user.home}/.m2/settings.xml. The folder starts with a dot, so Finder hides it. Choose Go > Go to Folder (⇧⌘G), paste ~/.m2, and press Return. From Terminal:
open ~/.m2
On the Mac used for this guide, ~/.m2 held only a repository folder (about 300 MB) and no settings.xml. That is normal: Maven creates the repository on first use, and the settings file only exists once you write one.
The repository is laid out by Maven coordinates, not by project. A dependency with group org.apache.commons and artifact commons-lang3 ends up under org/apache/commons/commons-lang3/<version>/, with the group's dots turned into folders. On the Mac used for this guide the top level had folders like antlr, asm, batik and bouncycastle, which are group names.
Inside a version folder you will usually find:
| File | What it is |
|---|---|
<artifact>-<version>.jar | The library itself. |
<artifact>-<version>.pom | Its project description and dependency list. |
*.sha1 | Checksum files Maven uses to verify downloads. |
_remote.repositories, *.lastUpdated | Bookkeeping files Maven writes while resolving. |
Maven plugins are cached here too, which is why a plain mvn package on a fresh machine downloads so much.
There are two settings files, and the user one wins:
${maven.home}/conf/settings.xml, inside the Maven installation. With Homebrew this sits under the libexec/conf of the installed formula; mvn -v prints the Maven home it is using.~/.m2/settings.xml.If both exist, Maven merges them and the user file takes precedence. Settings files can hold mirror URLs, server credentials and proxy details, so look at yours privately and never paste it into a chat or ticket. To start one, copy the global file into ~/.m2 and trim it.
du -sh ~/.m2/repository
du -sh ~/.m2/repository/* | sort -h | tail -10
Both read sizes only. Because everything is a download, none of it is precious.
Quit your IDE and any running build first, then either:
~/.m2/repository to the Trash in Finder for a full reset. The next build downloads what it needs again.Do not delete settings.xml casually: unlike the repository, it is your own configuration and cannot be downloaded back. Maven has no built-in "clean the repository" command in its core. The dependency plugin's mvn dependency:purge-local-repository, run inside a project, deletes that project's dependencies (transitive ones included) from the repository and, by default, downloads them again, which is the fix for one corrupted library.
Locally built artifacts count too. Running mvn install puts your own project into ~/.m2/repository, so deleting the repository also removes those, and you would need to run mvn install on those projects again.
Each Maven project also has its own target/ folder next to its pom.xml, holding compiled classes and the packaged jar from mvn package. That is build output for one project, not the shared repository. mvn clean removes it, and it is safe to delete by hand because the next build recreates it. Disk space often hides there as well as in ~/.m2, so check both when you are hunting for what grew.
Two documented ways:
settings.xml, set <localRepository>/Volumes/FastDrive/m2-repo</localRepository> (use your own path). Maven's settings page describes this element and notes it can use ${user.home} and ${env.X} placeholders.-Dmaven.repo.local=/path/to/repo for a single build. The settings page does not describe this property, but Maven 3.9.9, checked for this guide, recognises it.Move the existing contents across first, or the new location starts empty. IDEs read the same setting: IntelliJ IDEA and Eclipse both offer a Maven settings screen where you can see which settings.xml and local repository they use, though the exact menu names vary by version and should be checked in yours.
Copy settings.xml if you have one. Skip the repository: it is rebuilt on demand and often holds hundreds of megabytes or more of downloads. If you need to build without a network on the new Mac, copying ~/.m2/repository over works, since the layout is the same on every machine.
Spotlight and Finder searches leave out hidden dot-folders such as ~/.m2, so searching for a library's jar name in Finder returns nothing even when the jar is there.
Everywhere indexes file names in hidden folders. Typing commons-lang3 lists every cached version of that jar and pom under ~/.m2/repository, and typing settings.xml shows the global one inside the Maven installation and your user file, if you have made one. It searches names only, not what is inside the jars. Press ⌘↵ to reveal a result.
In your home folder: ~/.m2. It is hidden, so open it with Go to Folder (⇧⌘G) or open ~/.m2.
The user file is ~/.m2/settings.xml and the global one is conf/settings.xml inside the Maven installation. The user file takes precedence, and it does not exist until you create it.
Yes. Maven downloads dependencies again on the next build. Locally installed artifacts from mvn install are removed too, so rebuild those projects if you need them.
Set <localRepository> in ~/.m2/settings.xml, or pass -Dmaven.repo.local=<path> on the command line.
Everywhere keeps track of every file on your Mac — including the folders Spotlight hides and drives you have unplugged. Free for a day, then $19 once.
Version 2.20.3 · macOS 13+ · 4.7 MB · notarised