我对Maven快照的含义有点困惑,为什么我们要构建一个?


当前回答

通常在maven中,我们有两种类型的构建 1)建立快照 2)制定版本发布

快照构建:快照是特殊版本,它指示当前部署副本,不像常规版本,maven检查远程存储库中的每个构建的版本 因此快照构建只是开发构建。 发布版本:发布意味着在版本中删除快照,这些是常规的构建版本。

其他回答

快照仅仅意味着Maven将根据您的配置检查特定依赖项的最新更改。快照是不稳定的,因为它是在开发中,但如果在一个特殊的项目需要有最新的变化,你必须配置你的依赖版本为快照版本。这种情况发生在拥有多个产品的大型组织中,这些产品彼此密切相关。

“快照”术语意味着构建是给定时间内代码的快照。

这通常意味着这个版本仍在大量开发中。

当代码准备好并且是时候发布它时,您将希望更改POM中列出的版本。然后,您将使用“1.0”这样的标签,而不是使用“SNAPSHOT”。

有关版本控制的帮助,请查看语义版本控制规范。

understanding the context of SDLC will help understand the difference between snapshot and the release. During the dev process developers all contribute their features to a baseline branch. At some point the lead thinks enough features have accumulated then he will cut a release branch from the baseline branch. Any builds prior to this time point are snapshots. Builds post to this point are releases. Be noted, release builds could change too before going to production if any defect spot during the release testing.

顾名思义,快照指的是项目的状态及其在那个时刻的依赖关系。每当maven找到一个较新的项目SNAPSHOT时,它就下载并替换本地存储库中较旧的项目.jar文件。

快照版本用于正在进行开发的项目。如果您的项目依赖于正在积极开发的软件组件,那么您可以依赖于快照发布,并且当您运行构建时,Maven将定期尝试从存储库下载最新的快照。

我想谈谈术语。其他答案很好地解释了什么是Maven上下文中的“快照”版本。但是,非快照版本是否应该被称为“发布”版本呢?

在“发布”版本的语义版本控制思想之间存在一些紧张关系,“发布”版本似乎是任何没有-SNAPSHOT这样的限定符,但也没有-beta.4这样的限定符的版本;以及Maven的“发布”版本的想法,它似乎只包括没有-SNAPSHOT。

In other words, there is a semantic ambiguity of whether "release" means "we can release it to Maven Central" or "the software is in its final release to the public". We could consider -beta.4 to be a "release" version if we release it to the public, but it's not a "final release". Semantic versioning clearly says that something like -beta.4 is a "pre-release" version, so it wouldn't make sense for it to be called a "release" version, even without -SNAPSHOT. In fact by definition even -rc.5 is a release candidate, not an actual release, even though we may allow public access for testing.

因此,尽管Maven如此,在我看来,只将“发布”版本称为根本没有任何限定符(甚至没有-beta.4)的版本似乎更合适。对于Maven非快照版本来说,更好的名称可能是“稳定”版本(灵感来自另一个答案)。这样我们就有:

1.2.3-beta。4-SNAPSHOT:预发布版本的快照版本。 1.2.3-SNAPSHOT:发布版本的快照版本。 1.2.3-beta。4:预发布版本的稳定版本。 1.2.3:发布版本(显然是一个稳定的非快照版本)。