Sunday, December 27, 2009

Cleaning one's maven 2 local repository

Maven 2's local repository has a tendency to grow, and never shrink. This morning mine was 2.2Go big.

There are not many things you can do to remve unused items from that local repository. You'd first have to know what's unused?
I tend to simply delete my local repository altogether from time to time. Only when I am ready to wait a little while during the next build though. I usually to that at work as there we have a local proxy that makes things pretty seemless.

There is also the growing number of SNAPSHOTs that are produced and dowloaded by maven builds. They are easier and safer to get rid of. Here is a simple unix command to clean up your local repository of SNAPSHOTs:

find ~/.m2 -name *SNAPSHOT -type d | xargs rm -rf

2 comments:

  1. Thanks. The Windoze Batch equivalent would be
    FOR /F "tokens=*" %%G IN ('DIR /B /AD /S *SNAPSHOT') DO RMDIR /S /Q %%G

    ReplyDelete