Maven 发布插件 - tagBase 被忽略

Maven Release Plugin - tagBase is ignored

我正在尝试使用 Maven Release Plugin 创建一个版本,似乎 tagBase 设置被完全忽略了。

这是我的 pom 的样子:

...
<scm>
    <developerConnection>scm:svn:http://svn.server/svn/repos/.../project/trunk</developerConnection>
</scm>
...
<build>
    ...
    <plugins>
        ...
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>2.5.3</version>
            <configuration>
                <tagBase>http://svn.server/svn/repos/.../project/branches</tagBase>
            </configuration>
        </plugin>
    </plugins>
</build>
...

这是我 运行ning:

的 mvn 发布命令
mvn release:prepare

我最初使用 -DdryRun=true 选项尝试了此操作,并注意到由干 运行 生成的 pom.xml.tag 文件是引用 .../project/tags/ 目录而不是 tagBase 中指定的 .../projects/branches/ 目录。我在没有干 运行 的情况下尝试了这个,结果是一样的。该版本是在我的 SVN 存储库的 tags 目录中创建的,而不是根据 pom 中的 tagBase 设置在 branches 目录中创建的。

为什么 tagBase 被忽略了?如何获取 Maven 发布插件以在 .../project/branches/ 而不是 .../project/tags/ 下创建发布?

编辑 - 添加一些附加信息:

我使用的是 2.5.3 版的 maven-release-plugin 和 3.3.9 版的 Maven。

在 运行 执行 mvn release:prepare -DdryRun=true 命令后,下面是生成的 release.propertiespom.xml.tag 个文件看起来像:

release.properties:

#release configuration
#Thu Aug 25 09:07:24 EDT 2016
scm.tagNameFormat=@{project.artifactId}-@{project.version}
scm.tag=project-1.0.0
project.scm.group.id\:project.tag=HEAD
pushChanges=true
scm.url=scm\:svn\:http\://svn.server/svn/repos/.../project/trunk
preparationGoals=clean verify
remoteTagging=true
projectVersionPolicyId=default
scm.commentPrefix=[maven-release-plugin] 
scm.tagBase=http\://svn.server/svn/repos/.../project/branches
project.scm.group.id\:project.developerConnection=scm\:svn\:http\://svn.server/svn/repos/.../project/trunk
project.dev.group.id\:project=1.0.1-SNAPSHOT
project.rel.group.id\:project=1.0.0
exec.snapshotReleasePluginAllowed=false
exec.additionalArguments=-P my-active-profile
completedPhase=end-release

pom.xml.tag:

...
<scm>
    <developerConnection>scm:svn:http://svn.server/svn/repos/.../project/tags/project-1.0.0</developerConnection>
</scm>
...

看起来scm.tagBase属性在生成的release.properties文件中是正确的,但是[=47=中的scm信息]pom.xml.tag 仍然引用 tags 目录而不是 branches.

我开始研究 maven-release-plugin 代码和 maven-scm-provider-svn-commons 代码,我很确定我已经弄清楚为什么会这样。

如果 tagBase 属性 符合 SVN 存储库中 branches 目录的标准命名约定(例如 http://svn.server/svn/repo/project/branches),则 tagBase 被忽略以支持标准 tags 目录。以下是 maven-scm-provider-svn-commons 项目 1.9.4 版的相关代码:

SvnTagBranchUtils.java:

public static String resolveUrl( String repositoryUrl, String tagBase, String subdir, ScmBranch branchTag )
{
    ...
    // User has a tagBase specified so just return the name appended to the tagBase
    if ( StringUtils.isNotEmpty( tagBase ) && !tagBase.equals( resolveTagBase( repositoryUrl ) )
        && !tagBase.equals( resolveBranchBase( repositoryUrl ) ) )
    {
        return appendPath( tagBase, branchTagName );
    }
    ...
    return addSuffix( appendPath( appendPath( projectRoot, subdir ), branchTagName ), queryString );
}

如果 tagBase 与 SVN 存储库布局中的标准 /branches/ 目录匹配,则 !tagBase.equals( resolveBranchBase( repositoryUrl) ) 条件会阻止使用它。我什至能够使用与 /branches/ 目录(例如,http://svn.server/svn/repo/.../project/releases)不匹配的不同 tagBases 来测试它,并且它按预期工作。

不幸的是,我仍然不能 100% 确定在 运行 mvn release:prepare 时将发布写入 /branches/ 的最佳方式。我想我可能只是修改 maven-scm-provider-svn-commons 中的那部分代码,然后想办法让 maven-release-plugin 使用我修改后的 svn-commons.

版本

无论如何,我希望这可以帮助任何试图使用 maven-release-plugin 做类似事情的人。