In which circumstances is it safe respectively unsafe to rm -rf ~/.m2/repository
provided that I'm working online and I have access to all needed artifacts via remote repositories.
To clear/delete your local maven repository cache, simply delete the . m2/repository folder. The local repository path can also be configured in Maven setting. xml (either the global or the user one).
m2\repository on Windows. When you delete this folder, Maven creates the folder and downloads the dependencies for the projects you're building from then on.
Maven's local repository is a directory on the local machine that stores all the project artifacts. When we execute a Maven build, Maven automatically downloads all the dependency jars into the local repository. Usually, this directory is named .
All you could do, is to delete the . m2 folder and re-build all of your projects and then the folder would automatically build with all the required library.
When you retrieve all dependencies from remote repositories, then the local repo becomes nothing more than a cache.
Like all caches, the Maven local repo can occasionally become "dirty". In an acknowledged act of paranoia and overkill, I schedule a periodic cron job to purge the local repositories on my build machines. This forces a re-sync with my Nexus Maven repository.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With