I want to clean my local .m2 from all old versions of all artifacts. Leaving only the latest.
I'm aware of the mvn dependency:purge-local-repository option, but it works only with a specific project in mind, and processes only the current project dependencies.
I'm thinking of writing a script to crawl all over the folder and process it, but it feels there might be a better solution...
I want to clean ALL of the .m2.
Any ideas?
This depends on what you're trying to accomplish.
If you just want to reclaim disk space, you can remove all the SNAPSHOTs you have locally:
find ~/.m2/repository -name \*SNAPSHOT -type d -print0 | xargs -0 rm -rf
If you're trying to bundle up a minimal functional local repository for use on another machine, then I would rename my ~/.m2/repository; do the builds I need then tar up the results.
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