Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When is it safe to delete the local Maven repository?

Tags:

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.

like image 537
twigmac Avatar asked Apr 06 '12 22:04

twigmac


People also ask

Can I delete Maven local repository?

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).

What happens if I delete .m2 repository?

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.

What is local Maven repository?

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 .

Can I clean m2 repository?

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.


1 Answers

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.

like image 131
Mark O'Connor Avatar answered Oct 01 '22 00:10

Mark O'Connor