如何自定义Maven发布插件的标签格式?
在我们的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
发布插件现在支持
tagNameFormat
配置选项,默认为@{project.artifactId}-@{project.version}
。在您的情况下,您可以执行以下操作:请注意,为了确保在发布期间发生插值,您必须使用
@{...}
来引用属性而不是$ {...}
。The release plugin now supports the
tagNameFormat
configuration option, which defaults to@{project.artifactId}-@{project.version}
. In your case, you could do something like:Note that, in order to ensure that the interpolation occurs during release, you must use
@{...}
to reference the properties rather than${...}
.在修复以下错误之一之前,这似乎是不可能的:
It looks like this is not possible until one of these bugs is fixed:
如果您传递releaseVersion,您可以这样做:
If you are passing in the releaseVersion, you can do this: