Maven版本:批处理模式下的开发版本 [英] Maven release: next development version in batch mode

查看:103
本文介绍了Maven版本:批处理模式下的开发版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已配置Jenkins作业以自动释放我的maven项目.这是通过使用以下操作完成的:mvn --batch-mode clean release:prepare release:perform 在批处理模式下,将自动确定发行版本和开发版本.这正是我想要的.

I have configured a Jenkins job to release my maven project automatically. This is done by using the following: mvn --batch-mode clean release:prepare release:perform In batch mode the release version and the development version will be determined automatically. This is exactly what I want.

问题是我想增加版本的第二个而不是第三个.因此,当我发布版本1.2.0时,下一个开发版本必须是1.3.0-SNAPSHOT.不是1.2.1-SNAPSHOT. 添加命令行参数不是一种选择,因为这迫使我不断编辑构建作业.

The problem is that I want to increase the 2nd number of the version instead of the 3rd one. So when I release version 1.2.0, the next development version must be 1.3.0-SNAPSHOT. Not 1.2.1-SNAPSHOT. Adding a commandline parameter is not an option, because that forces me to constantly edit the build job.

关于如何更改用于确定下一个开发版本的算法的任何建议?

Any suggestions on how to change the algorithm used to determine the next development version?

推荐答案

我知道这是一篇过时的文章,但是我没有找到我真的很喜欢在线的答案,因此我提出了一些可行的方法对其他人来说很好...

I know this is a kinda old post but I didn't find an answer I really liked anywhere online and I was able to come up with something that might work well for others...

我希望在OP状态下增加minorVersion,并且可以通过在项目POM中结合使用build helper插件(用于解析版本)和release插件来实现.注意POM和maven run属性中引用的初始化"阶段.

I wanted to increment the minorVersion as the OP states, and I was able to do so by using a combination of the build helper plugin (to parse the version) and the release plugin, in my project POM. Note the "initialize" phase referenced in the POM and the maven run property...

这是POM的摘录,我们使用构建帮助器插件来解析可在发行插件中引用的版本...

Here's the excerpt from the POM, we use the build helper plugin to parse the version which we can reference in the release plugin...

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>${maven.build.helper.plugin.version}</version>
                <executions>
                    <execution>
                        <id>parse-versions-for-release</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>parse-version</goal>
                        </goals>
                        <configuration>
                            <propertyPrefix>parsedVersion</propertyPrefix>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>${maven.release.plugin.version}</version>
                <configuration>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <tagNameFormat>@{project.artifactId}-@{project.version}</tagNameFormat>
                    <useReleaseProfile>false</useReleaseProfile>
                    <developmentVersion>${parsedVersion.majorVersion}.${parsedVersion.nextMinorVersion}.0-SNAPSHOT</developmentVersion>
                </configuration>
            </plugin>

现在我们可以运行一个非常普通的发行版,但是要添加初始化"阶段以触发版本解析(并确保它在查找解析的版本之前发生)...

Now we can just run a pretty normal release, but adding in the "initialize" phase to trigger the version parsing (and ensure it occurs prior to looking for the parsed versions)...

mvn initialize release:clean release:prepare release:perform

这篇关于Maven版本:批处理模式下的开发版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆