如何自定义Maven发布插件的标签格式? [英] How to customise the tag format of the Maven release plugin?

查看:257
本文介绍了如何自定义Maven发布插件的标签格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的SVN存储库中,我们像这样存储标签:

In our SVN repo, we store tags like this:

trunk
    project_a
    project_b
branches
    project_a
        branch_x
        branch_y
    project_b
tags
    project_a
        1.0
        1.1
    project_b
        1.0

在项目上运行Maven发行插件的"准备"目标时A,默​​认情况下,它将标签创建为"tags/project_a-xx",这与我上面的标签命名方案不匹配.因此,我取决于发布者(即易犯错误的人)发现此问题并将标签更改为"tags/project_a/x.x".如何告诉发布插件默认使用正确的格式?

When I run the Maven release plugin's "prepare" goal on project A, by default it creates the tag as "tags/project_a-x.x", which does not match my tag naming scheme above. I am thus depending upon whoever does the release (i.e. a fallible human) to spot this and change the tag to "tags/project_a/x.x". How can I tell the release plugin to use the correct format by default?

准备"目标具有"标记"配置选项声称可以做到这一点,但是如果我将其设置如下:

The "prepare" goal has a "tag" configuration option that claims to do this, but if I set it as follows:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <version>2.1</version>
    <configuration>
        <tag>${project.artifactId}/${project.version}</tag>
    </configuration>
</plugin>

...,则创建的标签为"tags/project_a/x.x-SNAPSHOT",即它使用预发行版本号而不是发行版本号.将标签名称硬编码到POM中似乎也是错误的.

... then the created tag is "tags/project_a/x.x-SNAPSHOT", i.e. it uses the pre-release version number instead of the release version number. Hardcoding the tag name into the POM seems wrong too.

如何确保默认情况下标签正确无误?

How can I ensure that the tag is correct by default?

推荐答案

该发行版插件现在支持tagNameFormat

The release plugin now supports the tagNameFormat configuration option, which defaults to @{project.artifactId}-@{project.version}. In your case, you could do something like:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
        <tagNameFormat>@{project.artifactId}/@{project.version}</tagNameFormat>
    </configuration>
</plugin>

这篇关于如何自定义Maven发布插件的标签格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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