是否可以使用Maven POM文件为Maven发布插件配置GIT标签?

时间:2020-06-23 21:12:58

标签: maven maven-release-plugin

我想使用Maven Release插件通过向提交中添加GIT TAG来准备发布,其中版本号仅为例如1.0.0。而且我希望能够设置提交消息的前缀。 现在,默认标签是这样的:project-name-1.0.0。 提交消息也由maven Release插件在准备阶段添加,并且其前缀为:[maven-release-plugin]

这些默认值是在release:prepare阶段生成的,并将它们放入release.properties文件中。

我想在Maven POM文件中的某个位置设置变量default,以便每个Release的GIT标签和提交消息的前缀都具有相同的默认参数。

有人知道该怎么做吗?

这是我的POM文件的一部分,maven版本目前没有其他参数。

<scm>
        <connection>scm:git:https://example@example/mq-copy.git</connection>
        <url>https://example@example/mq-copy.git</url>
        <developerConnection>scm:git:https://example@example/mq-copy.git</developerConnection>
        <tag>HEAD</tag>
  </scm>

这是生成的release.properties文件:

#release configuration
#Tue Jun 23 22:30:00 CEST 2020
scm.tagNameFormat=@{project.artifactId}-@{project.version}
scm.tag=mq-copy-2.0.4
pushChanges=true
scm.url=scm\:git\:https\://example@example/mq-copy.git
preparationGoals=clean verify
project.dev.nl.bpittens.mq\:mq-copy=2.0.5-SNAPSHOT
remoteTagging=true
projectVersionPolicyId=default
scm.commentPrefix=[maven-release-plugin] 
project.scm.nl.bpittens.mq\:mq-copy.connection=scm\:git\:https\://example@example/mq-copy.git
project.scm.nl.bpittens.mq\:mq-copy.developerConnection=scm\:git\:https\://example@example/mq-copy.git
project.rel.nl.bpittens.mq\:mq-copy=2.0.4
project.scm.nl.bpittens.mq\:mq-copy.tag=HEAD
exec.snapshotReleasePluginAllowed=false
exec.additionalArguments=-P sagro
completedPhase=end-release
project.scm.nl.bpittens.mq\:mq-copy.url=https\://example@example/mq-copy.git

1 个答案:

答案 0 :(得分:0)

我找到了部分问题的答案。但这回答了这个特定问题。我只需要在插件部分的pom.xml文件中添加具有如下配置参数的插件即可:

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