I recently added Maven snapshot build capability to a project, configured to use unique timestamp version on deployed artifact. But there is some confusion regarding whether this is the right thing to do (snapshots in question are deployed to one of public repos, not just within an entity like company): some say it causes problems when trying to use snapshots.
我最近将Maven快照构建功能添加到项目中,配置为在部署的工件上使用唯一的时间戳版本。但是对于这是否是正确的事情存在一些混淆(有问题的快照被部署到公共存储库之一,而不仅仅是在像公司这样的实体中):有人说它在尝试使用快照时会导致问题。
So: given how much of Maven is convention based, and following perceived best practices, I am hoping there are some guidelines as to which option to choose.
所以:鉴于Maven有多少基于约定,并遵循感知的最佳实践,我希望有一些指导选择哪个选项。
(NOTE: I slightly edited the title -- I am specifically interesting in benefits (or lack thereof) of including unique timestamp, via deploy option, for public snapshot versions; not so much whether to make use of timestamps if they are included, although that is obviously somewhat related question)
(注意:我略微编辑了标题 - 我特别感兴趣的是在公共快照版本中包含唯一时间戳,通过部署选项的好处(或缺乏);如果包含时间戳,是否使用时间戳,尽管不是很多,尽管这显然是有点相关的问题)
2 个解决方案
#1
As a rule you should always build against the -SNAPSHOT dependency. However, you should avoid releasing your product if it includes -SNAPSHOT dependencies. If you use the Maven Release Plug-in to automate your release it will check to make sure you are not using release plug-ins or dependencies.
通常,您应始终针对-SNAPSHOT依赖项进行构建。但是,如果产品包含-SNAPSHOT依赖项,则应避免发布产品。如果您使用Maven Release Plug-in自动发布,它将检查以确保您没有使用发布插件或依赖项。
But that is not always possible. In cases where I need to release something based on a snapshot build that is when I use the explicit timestamp/build number rather than the -SNAPSHOT version naming scheme.
但这并非总是可行的。在我需要基于快照构建发布内容的情况下,当我使用显式时间戳/内部版本号而不是-SNAPSHOT版本命名方案时。
You can automate this using the Versions Maven Plugin. It provides goals to lock and unlock snapshot versions in your POM.
您可以使用Versions Maven插件自动执行此操作。它提供了锁定和解锁POM中快照版本的目标。
#2
The whole point of a snapshot is to let someone use the latest version of the code. Why would you want to use a snapshot five versions back?
快照的重点是让某人使用最新版本的代码。为什么要使用快照五个版本?
With that in mind, what do timestamps in the artifact name buy you?
考虑到这一点,工件名称中的时间戳会为您带来什么?
I've been using Maven for about 5 years now. I've never seen a snapshot jar with a timestamp in the name.
我已经使用Maven大约5年了。我从未见过名字中带有时间戳的快照jar。
#1
As a rule you should always build against the -SNAPSHOT dependency. However, you should avoid releasing your product if it includes -SNAPSHOT dependencies. If you use the Maven Release Plug-in to automate your release it will check to make sure you are not using release plug-ins or dependencies.
通常,您应始终针对-SNAPSHOT依赖项进行构建。但是,如果产品包含-SNAPSHOT依赖项,则应避免发布产品。如果您使用Maven Release Plug-in自动发布,它将检查以确保您没有使用发布插件或依赖项。
But that is not always possible. In cases where I need to release something based on a snapshot build that is when I use the explicit timestamp/build number rather than the -SNAPSHOT version naming scheme.
但这并非总是可行的。在我需要基于快照构建发布内容的情况下,当我使用显式时间戳/内部版本号而不是-SNAPSHOT版本命名方案时。
You can automate this using the Versions Maven Plugin. It provides goals to lock and unlock snapshot versions in your POM.
您可以使用Versions Maven插件自动执行此操作。它提供了锁定和解锁POM中快照版本的目标。
#2
The whole point of a snapshot is to let someone use the latest version of the code. Why would you want to use a snapshot five versions back?
快照的重点是让某人使用最新版本的代码。为什么要使用快照五个版本?
With that in mind, what do timestamps in the artifact name buy you?
考虑到这一点,工件名称中的时间戳会为您带来什么?
I've been using Maven for about 5 years now. I've never seen a snapshot jar with a timestamp in the name.
我已经使用Maven大约5年了。我从未见过名字中带有时间戳的快照jar。