Maven Pom.xml自动增量版本 [英] Maven Pom.xml Auto Increment Version

查看:445
本文介绍了Maven Pom.xml自动增量版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几天来,我一直在试图解决这个问题,我在stackoverflow上一直都在寻找,没有一个答案可以解决我的问题.我试图在我的Pom.xml中包含<version>.

I've been trying to figure this out for a few days now, I have looked all over stackoverflow and none of the answers fix my issue. I am trying to have the <version> in my Pom.xml.

<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>maven.Test</groupId>
  <artifactId>Hello</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>jar</packaging>

<distributionManagement>
    <repository>
        <id>Artifactory</id>
        <name>Artifactory-releases</name>
        <url>${publish.location}</url>
    </repository>
    <snapshotRepository>
        <id>Artifactory</id>
        <name>Artifactory-snapshots</name>
        <url>${publish.location}</url>
    </snapshotRepository>
</distributionManagement>

</project>

我目前正在使用Maven 3.3.3,我已经研究了SCM插件,但是这些插件似乎没有用.我知道您可以通过将其设置为变量来使版本递增,但这对我的开发人员而言并不理想.使用命令mvn deploy运行构建时,我希望版本自动增加到1.0.1,依此类推.

I am using Maven 3.3.3 currently, I have looked into SCM plugins but those don't seem to be working. I know you can have it increment versions by setting them as variables but that isn't ideal for my developers. When a build is run using the command mvn deploy I want the version to auto increment to 1.0.1 and so on.

我尝试进行Maven发布,但是遇到了可能是我遇到的问题.对于发布插件,我需要对Pom.xml进行编辑吗?我遇到了mvn release:prepare,但是遇到了这个错误:

I tried doing the maven release but am running into an issue which may be on me. For the release plugin are there edits I need to make to my Pom.xml? I ran mvn release:prepare but ran into this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.3
.2:prepare (default-cli) on project Hello: Unable to check for local modificatio
ns
[ERROR] Provider message:
[ERROR] The svn command failed.
[ERROR] Command output:
[ERROR] 'svn' is not recognized as an internal or external command,
[ERROR] operable program or batch file.

推荐答案

选择@rec的答案:

使用:

$ mvn -B release:prepare release:perform

请注意-B.它会以批处理模式运行,而发行插件根本不会问.

Note the -B. It will run in batch mode and the release plugin won't ask at all.

这篇关于Maven Pom.xml自动增量版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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