简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM