Eldad Assis
Eldad Assis

Reputation: 11045

Maven - purge local .m2 from all old artifacts versions

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?

Upvotes: 4

Views: 1804

Answers (1)

Idcmp
Idcmp

Reputation: 691

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.

Upvotes: 2

Related Questions