有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java当我使用mavenreleaseplugin发布分支时,为什么它会尝试从修订版0创建分支?

我正在使用maven发布插件。我试图释放一个分支,但当它尝试执行此命令时失败:

cmd.exe /X /C "svn --non-interactive copy --file C:\Users\USER~1\AppData\Local\Temp\maven-scm-711744598.commit --parents --revision 0 https://domain/svn/app/branches/2.4.8.x https://domain/svn/app/tags/App-2.4.8.1"

它给出了以下错误:

svn: E195012: Unable to find repository location for 'https://domain/svn/app/branches/2.4.8.x' in revision 0

我认为这是在准备目标中发生的,因为当它失败时,它会说:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5:prepare

我问了一位svn专家,他说:

wait, why is it trying to copy something from r0? By definition there is nothing in r0. r0 is always an empty repository, the first objects are added in r1. That's why it fails. the question is why maven tried it. If you supply a revision argument to 'svn copy' then the branch / tag you create is based on the source from the revision you specify so the source has to exist in that revision (if you don't specify, you get HEAD, i.e., the newest revision) ...and as for that, I know nothing about maven or its plugins

那么,为什么maven试图从修订版0复制?这是我运行的maven命令:

mvn --batch-mode release:prepare release:perform

我的根pom的maven发布插件定义如下:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>2.5</version>
            <configuration>
                <autoVersionSubmodules>true</autoVersionSubmodules>
                <developmentVersion>2.4.8.2-SNAPSHOT</developmentVersion>
                <releaseVersion>2.4.8.1</releaseVersion>
                <branchBase>https://domain/svn/app/branches</branchBase>
                <tagBase>https://domain/svn/app/tags</tagBase>
            </configuration>
        </plugin>

此外,我的scm标记如下所示:

<scm>
    <connection>scm:svn:https://domain/svn/app/branches/2.4.8.x</connection>
</scm>

我的svn版本是1.8.5(r1542147)


共 (3) 个答案

  1. # 1 楼答案

    我也有这个问题。在受影响的项目中,我在验证阶段对一些文件进行了自定义搜索和替换,我想在标记之前签入对Svn的更改,因此我添加了如下自定义签入操作:

            <plugin>
                <artifactId>maven-release-plugin</artifactId>
                <configuration>
                    <preparationGoals>clean verify scm:checkin -Dmessage="perform release"</preparationGoals>
                </configuration>
            </plugin>
    

    这样做的结果是,当发布插件尝试检入pom文件中的更改时,没有任何更改,因为这些更改已经由自定义操作提交。从而导致这个错误

    我在我的自定义scm:checkin中添加了一个“包含”文件列表,其中只包含我篡改过的文件,这为我解决了这个问题

    生成的配置如下所示:

            <plugin>
                <artifactId>maven-release-plugin</artifactId>
                <configuration>
                    <preparationGoals>clean verify scm:checkin -Dmessage="perform release" -Dincludes="TwogWebUtilsGrailsPlugin.groovy,plugin.xml" -DconnectionType="connection"</preparationGoals>
                </configuration>
            </plugin>
    

    我的自定义替换操作的原因是因为该项目是一个Grails插件,并且我遵循了this blog post中的指导原则

    后期编辑:升级到maven 3.2后,这个解决方案似乎崩溃了。我回到了我开始的地方

  2. # 2 楼答案

    正如我在上述评论中所说:

    I cleaned up EVERYTHING and ran just release:prepare by itself and it succeeded without issue. Perhaps this is a bug where running release:prepare and release:perform together will cause this

    自从分别运行这些命令以来,我没有遇到过这个问题

  3. # 3 楼答案

    只是想添加这个迟来的答案,如果有人有同样的问题,并且在评论中的解决方案不起作用
    我们在一个多模块应用程序中也遇到了同样的问题,只有我们的父POM有SCM标记(它在我们的其他应用程序中工作得非常好)。我们得到了相同的错误,但可以通过向每个子POM添加相应的SCM标记来解决。我们从未发现这是为什么