如何阻止 Maven/Artifactory 保留带时间戳的快照
-
12-09-2019 - |
题
出于磁盘空间的考虑,我只想在我的存储库中保留任何快照的一个版本。而不是保留带有时间戳后缀的多个版本
例如电子商务-2.3-20090806.145007-1.ear
我该如何设置?这是构建设置还是存储库 (Artifactory) 设置
谢谢!
解决方案
最简单的(和 受到推崇的)方式是使用非唯一快照。如果必须使用唯一快照,则可以通过在artifactory.config.xml 中的<localRepository> 定义上指定<maxUniqueSnapshots> 属性,在Artifactory 中执行此操作
例如:
<localRepository>
<key>snapshots</key>
<blackedOut>false</blackedOut>
<handleReleases>false</handleReleases>
<handleSnapshots>true</handleSnapshots>
<maxUniqueSnapshots>1</maxUniqueSnapshots>
<includesPattern>**/*</includesPattern>
<snapshotVersionBehavior>non-unique</snapshotVersionBehavior>
</localRepository>
作为参考,您可以在 关系 (通过 UI)通过设置 定期服务, ,它允许您指定要保留的最小数量、保留它们的最长期限,以及在部署发布版本时是否删除快照。
其他提示
注意,此功能/能力已被移除IN MAVEN 3.0 强>
只是讲一下我自己的问题:
添加
<distributionManagement>
...
<snapshotRepository>
...
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
...
</distributionManagement>
到我的父 POM 也促成了这种解决方案。
请参阅:
http://i-proving.com/space / Jessamyn +史密斯/博客/ 2008-06-16_1
要改变在Artifactory的资源库中的独特设置 - 登录为管理员 - 并选择相关的回购编辑 - 截图在这里:
Artifactory的可以清理旧独特快照。然而,我们发现独特的快照是依赖或滚动回追踪到特定版本的目的无用。有这样做的更好的替代品,这是更清洁,更可靠。这就是为什么Artifactory的默认为喜欢非唯一的快照,并且该策略可以是中央控制(这是唯一的artifactory的)。 你可以阅读更多关于这一点,以及自动清理功能的此处。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>remove-old-artifacts</id>
<phase>package</phase>
<goals>
<goal>remove-project-artifact</goal>
</goals>
<configuration>
<removeAll>true</removeAll><!-- When true, remove all built artifacts including all versions. When false, remove all built artifacts of this project version -->
</configuration>
</execution>
</executions>
</plugin>
使用非唯一的快照是不是一个很好的路要走。相反,得到一个仓库管理器,可以清理快照和配置,为了保持磁盘空间了。具有时间戳的快照使得它更容易追查的问题,因为你可以很容易地看到实际正在使用哪个版本。
不会在Maven的3工作,因为它是由下面的Apache
引It's not recommended to use non-unique snapshots since they lead to non-reproducible builds. The main use case for these was to save disk space in the repository, but this is best handled by scheduling a periodic snapshot removal task to keep the number of versions down