现在maven-3确实放弃了对
以前将最佳快照设置为uniqueVersion = false 似乎是最佳做法
现在,切换到带时间戳的版本似乎没什么大问题,毕竟它们是由中央nexus存储库管理的,它可以在常规的intervalls中删除旧的快照.
问题是本地开发人员工作站.他们的本地存储库通过独特的快照很快变得非常大.
如何处理这个问题?
现在我看到了以下可能的解决方案:
要求开发人员定期清除存储库(这导致很多因为需要很长时间才能删除,甚至更长时间才能下载所需的所有内容)
设置一些脚本,它会从本地存储库中删除所有SNAPSHOT目录,并要求开发人员不时运行该脚本(比第一个更好,但仍需要相当长的时间来运行和下载当前快照)
使用依赖:purge-local-repository插件(从eclipse运行时有问题,由于打开文件,需要从每个项目运行)
在每个工作站上设置nexus并设置一个工作来清理旧快照(最好的结果,但我不想维护50多个nexus服务器,而且开发人员工作站上的内存总是很紧张)
完全停止使用SNAPSHOTS
保持本地存储库填满硬盘空间的最佳方法是什么?
更新:
为了验证beaviour并提供更多信息,我设置了一个小的nexus服务器,构建两个项目(a和b)并尝试:
A:
4.0.0 de.glauche a 0.0.1-SNAPSHOT nexus nexus http://server:8081/nexus/content/repositories/snapshots
b:
4.0.0 de.glauche b 0.0.1-SNAPSHOT nexus nexus http://server:8081/nexus/content/repositories/snapshots/ nexus nexus true http://server:8081/nexus/content/repositories/snapshots/ de.glauche a 0.0.1-SNAPSHOT
Now, when i use maven and run "deploy" on "a", i'll have
a-0.0.1-SNAPSHOT.jar a-0.0.1-20101204.150527-6.jar a-0.0.1-SNAPSHOT.pom a-0.0.1-20101204.150527-6.pom
in the local repository. With a new timestamp version each time i run the deploy target. The same happens when i try to update Snapshots from the nexus server (close "a" Project, delete it from local repository, build "b")
In an environment where lots of snapshots get build (think hudson server ...), the local reposioty fills up with old versions fast
Update 2:
To test how and why this is failing i did some more tests. Each test is run against clean everything (de/glauche gets delete from both machines and nexus)
mvn deploy with maven 2.2.1 :
local repository on machine A does contain snapshot.jar + snapshot-timestamp.jar
BUT: only one timestamped jar in nexus, metadata reads:
de.glauche a 0.0.1-SNAPSHOT 20101206.200039 1 20101206200039
run update dependencies (on machine B) in m2eclipse (embedded m3 final) -> local repository has snapshot.jar + snapshot-timestamp.jar :(
run package goal with external maven 2.2.1 -> local repository has snapshot.jar + snapshot-timestamp.jar :(
Ok, next try with maven 3.0.1 (after removing all traces of project a)
local repository on machine A looks better, only one one non-timestamped jar
only one timestamped jar in nexus, metadata reads:
de.glauche a 0.0.1-SNAPSHOT
20101206.201808 3 20101206201808 jar 0.0.1-20101206.201808-3 20101206201808 pom 0.0.1-20101206.201808-3 20101206201808
run update dependencies (on machine B) in m2eclipse (embedded m3 final) -> local repository has snapshot.jar + snapshot-timestamp.jar :(
run package goal with external maven 2.2.1 -> local repository has snapshot.jar + snapshot-timestamp.jar :(
So, to recap: The "deploy" goal in maven3 works better than in 2.2.1, the local repository on the creating machine looks fine. But, the receiver always ends up with lots of timestamed versions ...
What am i doing wrong ?
Update 3
我还测试了各种其他配置,首先用神器代替nexus - >相同的行为.然后使用linux maven 3客户端从存储库管理器下载快照 - >本地存储库仍然有时间戳快照:(
该
配置应用于已部署(通过mvn deploy)到Maven存储库(如Nexus)的工件.
要从Nexus中删除这些内容,您可以轻松创建自动作业,以便每天清除SNAPSHOT存储库.它可以配置为保留一定数量的shapshots或保持一段时间.它超级简单,效果很好.
开发人员机器上的本地存储库中的工件从"安装"目标到达那里并且不使用这些时间戳...他们只是一直替换SNAPSHOT版本,除非您也在增加修订版本号(例如1.0.0- SNAPSHOT到1.0.1-SNAPSHOT).
此插件从本地存储库中删除项目的工件.仅用于保留大型本地快照的一个副本很有用.
org.codehaus.mojo
build-helper-maven-plugin
1.7
remove-old-artifacts
package
remove-project-artifact
true
好吧,我不喜欢任何提议的解决方案.删除maven缓存通常会显着增加网络流量并减慢构建过程.建立辅助性Maven的插件有助于只有一个神器,我想解决方案,可以清除从本地缓存中的所有过时的时间戳快照文物在一个简单的命令.经过几天的搜索,我放弃了,决定写小程序.最终的计划似乎在我们的环境中运作良好.所以我决定与可能需要这种工具的其他人分享.来源可以从GitHub拉:https://github.com/nadestin/tools/tree/master/MavenCacheCleanup