如何自定义Maven发布插件的标签格式?

发布于 2024-10-07 16:42:11 字数 1114 浏览 11 评论 0原文

在我们的 SVN 存储库中,我们存储如下标签:

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 发布插件的“prepare ”项目 A 上的目标,默认情况下它会将标签创建为“tags/project_a-xx”,这与我上面的标签命名方案不匹配。因此,我依赖于发布的人(即容易犯错的人)来发现这一点并将标签更改为“tags/project_a/xx”。我如何告诉发布插件默认使用正确的格式?

“prepare”目标有一个“tag”配置选项,声明为此,但如果我将其设置如下:

<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/xx-SNAPSHOT”,即它使用预发布版本号而不是发布版本号。将标签名称硬编码到 POM 中似乎也是错误的。

如何确保默认标签是正确的?

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

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>

... 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

っ左 2024-10-14 16:42:11

发布插件现在支持 tagNameFormat 配置选项,默认为@{project.artifactId}-@{project.version}。在您的情况下,您可以执行以下操作:

<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>

请注意,为了确保在发布期间发生插值,您必须使用 @{...} 来引用属性而不是 $ {...}

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>

Note that, in order to ensure that the interpolation occurs during release, you must use @{...} to reference the properties rather than ${...}.

与酒说心事 2024-10-14 16:42:11

在修复以下错误之一之前,这似乎是不可能的:

  • MRELEASE-150:无法在不影响版本的情况下向标签添加前缀(未计划)
  • MRELEASE- 159:支持生成发布标签的模式(计划用于 2.2)
  • MRELEASE-259:为发布时使用的默认标签/标签提供配置设置(未计划)

It looks like this is not possible until one of these bugs is fixed:

  • MRELEASE-150: Can't add prefix to tags without affecting version (not scheduled)
  • MRELEASE-159: Support a pattern to generate the release tag (scheduled for 2.2)
  • MRELEASE-259: Provide a configuration settings for default tag/label to use when releasing (not scheduled)
感情洁癖 2024-10-14 16:42:11

如果您传递releaseVersion,您可以这样做:

<tag>${project.artifactId}/${releaseVersion}</tag>

If you are passing in the releaseVersion, you can do this:

<tag>${project.artifactId}/${releaseVersion}</tag>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文