简体   繁体   English

清理Maven存储库-删除每个文件夹x个最新文件以外的所有文件

[英]Clean a maven repository - Delete all files except the x newest per folder

I would like to clean my local maven repository, but keep the last y snapshot versions for each artifact. 我想清理我的本地Maven存储库,但为每个工件保留最新的y快照版本。

I found this script but it works by date. 我找到了此脚本,但按日期可以使用。 I think I could adapt it to make it count files, but I'd like to know if such thing could be done directly with a linux find command. 我想我可以对其进行调整以使其计数文件,但是我想知道是否可以使用linux find命令直接完成此操作。 Any idea? 任何想法?

Thanks 谢谢

If you have an in-house repository manager it's probably simpler to clear your local repository and let it populate itself again over time. 如果您有内部存储库管理器,则清除本地存储库并随时间推移再次填充自身可能更简单。

If you do not have a repository manager, get one, even if it is just for yourself. 如果您没有存储库管理器,即使只有您自己也可以找到一个。 I use Nexus , but there are alternatives. 我使用Nexus ,但还有其他选择。 Nexus let's you decide how many snapshots to keep and/or for how long. Nexus让您决定保留多少快照和/或保留多长时间。 In the end it's going to be easier to manage artifact lifetime with Nexus rather than try to devise complicated scripts. 最后,使用Nexus管理工件寿命将比尝试设计复杂的脚本要容易得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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