简体   繁体   English

SVN中的Maven发布周期和版本控制

[英]Maven release cycle and versioning in SVN

I'm trying to find some solid information on the version numbers and branching/merging with Maven and SVN. 我试图找到有关版本号以及与Maven和SVN分支/合并的可靠信息。

My projects use the Maven version rules: 我的项目使用Maven版本规则:

<major>.<minor>.<revision>([ -<qualififer> ] | [ -<build> ])

My Maven release is as follows with snapshots in the trunk and release tags 我的Maven版本如下,主干和版本标签中有快照

trunk:    1.0.0-SNAPSHOT

tag:      1.0.0

trunk:    1.0.1-SNAPSHOT

tag:      1.0.1

etc....

Questions: 问题:

  1. If I create a branch (from a release tag) in order to do a bugfix. 如果我创建分支(从发布标签)以进行错误修复。 When it comes to releasing this patch what number does the maven release plugin give it? 当涉及到发布此补丁时,maven版本插件会给它提供多少编号? What tag name does it get? 它得到什么标签名称? Any recommendation on merging changes back into trunk? 关于将更改合并回主干的任何建议?

  2. What is the standard approach to changing the Maven version numbers? 更改Maven版本号的标准方法是什么? When do the Major, Minor and build numbers get incremented? 专业,次要和内部编号何时增加?

Any books or documentation that can shed some light on the recommended approach? 是否有任何书籍或文档可以帮助您了解建议的方法?

A quote from Better Builds with Maven - Mergere Library Press. 引用Maven的“更好的构建” -Mergere图书馆出版社。

Section 3.6. 3.6节。 Resolving Dependency Conflicts and Using Version Ranges: 解决依赖性冲突并使用版本范围:

在此处输入图片说明

If I create a branch (from a release tag) in order to do a bugfix. 如果我创建分支(从发布标签)以进行错误修复。 When it comes to releasing this patch what number does the maven release plugin give it? 当涉及到发布此补丁时,maven版本插件会给它提供多少编号? What tag name does it get? 它得到什么标签名称? Any recommendation on merging changes back into trunk? 关于将更改合并回主干的任何建议?

When doing mvn release:prepare , You will get chance to fill specific version name (release version, tag version, next trunk version and etc.) if you don't like the one Maven generated. 当执行mvn release:prepare ,如果您不喜欢生成一个Maven,则将有机会填写特定的版本名称(发行版本,标签版本,下一个中继版本等)。 In some special case for instance build a patch release from branch, we usually set version name by ourselves: 例如,在某些特殊情况下,从分支机构构建补丁发行版,我们通常会自行设置版本名称:

  • If changes doesn't need to merge back to trunk (build release from branch), use 1.0.1-1 or 1.0.1-patch-1. 如果不需要将更改合并回主干(分支的内部版本),请使用1.0.1-1或1.0.1-patch-1。

  • If changes need to merger back to trunk (build release from trunk), for major change, use 2.0.0, for minor change, use 1.1.0, for bug fix, use 1.0.2. 如果更改需要合并回主干(从主干构建发行版),对于主要更改,请使用2.0.0;对于次要更改,请使用1.1.0;对于错误修复,请使用1.0.2。

What is the standard approach to changing the Maven version numbers? 更改Maven版本号的标准方法是什么? When do the Major, Minor and build numbers get incremented? 专业,次要和内部编号何时增加?

See the diagram above. 参见上图。

Update: 更新:

Yes this is another confusing part of maven versioning. 是的,这是Maven版本控制中另一个令人困惑的部分。 For me the diagram contradicts whats written below it: It states the build number is incremented after releasing a patch. 对我来说,该图与下面的内容矛盾:它指出发行补丁后版本号会增加。 But I thought that was what the Bug fix part of the version string is for as shown in diagram?? 但是我认为这就是如图所示的版本字符串的Bug修复部分?

The purpose of maven version ranges is to cover as many use cases as possible. Maven版本范围的目的是覆盖尽可能多的用例。 How you intend to use it is completely up to you. 您打算如何使用它完全取决于您。 The point here is which one is more reasonable. 这里的重点是更合理。 As I have stated in the original post, it is used in some special case, like your team need maintain two work stream simultaneously (main work stream on trunk and second work stream on branch). 正如我在原始帖子中所说的,它用于某些特殊情况,例如您的团队需要同时维护两个工作流(主干在分支上,第二个工作在分支上)。

Take this scenario as an example, after a long time of work, you build and deploy release 1.0.6 to your clients (in SVN, 1.0.6 is tagged and trunk is incremented to 1.0.7-SHAPSHOT, means next expected release version is 1.0.7), and continuously developing on trunk. 以这种情况为例,经过长时间的工作,您将发行版本1.0.6部署并部署到客户端(在SVN中,标记了1.0.6,主干增加到1.0.7-SHAPSHOT,这意味着下一个预期的发行版本是1.0.7),并且在主干上不断发展。 Then two weeks later, a bug is reported in release 1.0.6 and requires urgent fix, so you create a branch from tag 1.0.6, fix the bug and merge branch back to trunk. 然后,两周后,在1.0.6版中报告了一个错误,需要紧急修复,因此您可以从标记1.0.6创建分支,修复该错误并将分支合并回主干。 Now you need build a patch release for client. 现在,您需要为客户端构建一个修补程序版本。 As trunk has been changed quite a lot since last build (two weeks ago), we have to build this patch release from branch. 自从上次构建(两周前)以来,主干已经进行了很多更改,因此我们必须从分支构建此补丁程序版本。 Of cause, you can use anything you like (ie 1.0.7) for this patch release, which as a consequence need manually alter version in trunk (from 1.0.7-SHAPSHOT to 1.0.8-SNAPSHOT). 当然,您可以为该修补程序版本使用任何喜欢的名称(即1.0.7),因此需要手动更改中继中的版本(从1.0.7-SHAPSHOT更改为1.0.8-SNAPSHOT)。 However, I would prefer to use 1.0.6-patch-1 for this patch release. 但是,我更喜欢在此补丁程序发行版中使用1.0.6-patch-1。

Nothing is contradict in the diagram, the build number is perfect in this scenario, this is what it means "while the build number is an increment after release to indicate patched builds." 图中没有矛盾,在这种情况下内部版本号是完美的,这意味着“内部版本号是发行后的增量,表示已修补的内部版本”。 It gives you a second chance to increment version targeting on an already-released version (1.0.6 -> 1.0.6-patch-1), not a ready-to-release development version (1.0.7-SNAPSHOT -> 1.0.7). 它给您第二次机会来增加针对已发布版本(1.0.6-> 1.0.6-patch-1)的版本,而不是立即发布的开发版本(1.0.7-SNAPSHOT-> 1.0)。 7)。

I would suggest to create a different numbering schemata in this case. 在这种情况下,我建议创建一个不同的编号模式。 So let us assume we create a branch from 1.0.0 Tag which might be named like 1.0.0-BFB. 因此,让我们假设我们从1.0.0标签创建了一个分支,该分支的名称可能类似于1.0.0-BFB。 The version for the maven artifacts i would use a thing like this: Maven工件的版本,我将使用以下内容:

1.0.0.1-SNAPSHOT 

If you release this artifact the version number will go to: 如果释放此工件,则版本号将为:

1.0.0.1

This a solution for a single change which can simply be enhanced having multiple changes on the 1.0.0 line like this. 这是针对单个更改的解决方案,可以简单地对其进行增强,例如在1.0.0行上具有多个更改。 Create the branch from 1.0.0 tag and name it like MB-1.0.0 and the version for the artifacts can be done like: 从1.0.0标记创建分支并将其命名为MB-1.0.0,并且工件的版本可以像以下那样进行:

1.0.0.1-SNAPSHOT
1.0.0.1
1.0.0.2-SNAPSHOT
1.0.0.2
1.0.0.3-SNAPSHOT
etc.

By default the tag name in Maven is calculated by the name of the artifactId and the version. 默认情况下,Maven中的标签名称是根据artifactId的名称和版本来计算的。

The creation of such a maintenance branch can be done by the release plugin like this: 这样的维护分支的创建可以通过发布插件来完成,如下所示:

mvn -B -DupdateBranchVersions=true -DupdateWorkingCopyVersions=false -DreleaseVersion=1.0.1-SNAPSHOT -DbranchName=MB-1.0.0 release:branch

The default solution to handle this situation is to use the parameters for the release plugin where you can use the developmentVersion or the releaseVersion as well. 处理这种情况的默认解决方案是使用release插件的参数,您也可以在其中使用developmentVersion或releaseVersion。 This will only work if you know that before you do the release. 只有在发布之前知道这一点,这才起作用。

But the usual case that you made a release and decided later to change the minor or major version. 但是通常情况是您发布了一个版本,后来又决定更改次要或主要版本。 So you can use the release plugin as well like: 因此,您也可以使用release插件:

mvn org.apache.maven.plugins:maven-release-plugin:2.3.2:update-versions -DdevelopmentVersion=WhatEverVersionYouLike

Or you can use the versions-maven-plugin to update the version numbers. 或者,您可以使用versions-maven-plugin更新版本号。

You have complete control on what versions are given to your artifacts at release time. 您可以完全控制在发布时为工件指定的版本。

Generally, with major.minor.patch versioning scheme the idea is that patch part is incremented for bug fixes, minor - for new features not breaking backward compatibility, major - backward incompatible changes and new major features. 通常,对于major.minor.patch版本控制方案,其思想是:针对漏洞修复,针对次要的(针对不破坏向后兼容性的新功能),针对次要的(向后不兼容的更改)以及新增的主要功能,对补丁程序部分进行递增。

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

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