处理项目版本属性以删除SNAPSHOT吗? [英] Manipulate project version property to remove SNAPSHOT?

查看:185
本文介绍了处理项目版本属性以删除SNAPSHOT吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个版本为0.0.1-SNAPSHOT的项目,当我们通过TeamCity进行构建时,我们还获得了一个build.vcs.number属性,该属性是触发构建的Subversion修订版.

I've got a project at version 0.0.1-SNAPSHOT, and when we build it via TeamCity, we also get a build.vcs.number property, which is the Subversion revision that triggered the build.

在我们的程序集中,我们创建了一个名为foo-distribution-0.0.1-SNAPSHOT.zip之类的zip文件,但是我想知道是否有一种方法可以将build.vcs.number属性插入到工件名称中,以给foo-distribution-0.0.1.12345-SNAPSHOT.zip?

In our assemblies, we create a zip file called something like foo-distribution-0.0.1-SNAPSHOT.zip, but I was wondering whether there's a way I can insert the build.vcs.number property into the artifact name to give foo-distribution-0.0.1.12345-SNAPSHOT.zip?

是否有一个内置属性只是版本号的数字部分,还是通过其他方式分割-SNAPSHOT部分?

Is there a built-in property that is just the numeric part of the version number, or some other way of splitting off the -SNAPSHOT part?

我已经尝试过将pom.xml版本设置为$ {my.version} -SNAPSHOT,然后在属性中定义my.version-这在除Maven Release Plugin之外的所有情况下都适用,它抱怨说它无法解析版本(可以理解,它也不能自动猜测下一个开发版本).

I have already tried setting the pom.xml version as ${my.version}-SNAPSHOT, and then defining my.version in the properties - this works for ever case except for the Maven Release Plugin, which complains that it cannot parse the version (understandably, it can't auto-guess the next development version either).

推荐答案

我意识到这个问题有些陈旧,但是我遇到了类似的情况,这就是我的解决方法:

I realize this question is a tad dated, but I just ran into a similar situation, and this is how I resolved it:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>1.8</version>
    <executions>
      <execution>
        <id>parse-version</id>
        <goals>
          <goal>parse-version</goal>
        </goals>
      </execution>
    </executions>
</plugin>

此构建助手插件的"parse-version" mojo会执行的操作是为您提供以下属性,您可以根据需要使用它们:

What this build-helper plugin's "parse-version" mojo will do is give you the following properties that you can use as you see fit:

parsedVersion.majorVersion
parsedVersion.minorVersion
parsedVersion.incrementalVersion
parsedVersion.qualifier
parsedVersion.buildNumber

这应该涵盖您所需的所有版本零件".我目前正在使用它来构建chrome扩展名,其中清单版本不能包含"-SNAPSHOT",并且最多不能超过4个数字,并用点号分隔.在我的用例中,我使用这种组合来产生期望的结果:

That should cover all of your desired version "parts." I'm currently using this to build chrome extensions in which the manifest version cannot include "-SNAPSHOT" and must be at most 4 numbers separated by dots. In my use case, I use this combination to produce the desired result:

"version":"${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}"

因此,我实质上是在剥离"-SNAPSHOT",因此我的扩展程序的本地dev副本将正确安装以进行测试.您可以用这些零件构建任何想要的东西. =)

So, I'm essentially stripping of "-SNAPSHOT" so my local dev copies of my extension will install properly for testing. You can build whatever you want with the pieces. =)

这篇关于处理项目版本属性以删除SNAPSHOT吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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