【问题标题】:How to migrate Maven Release Plugin to from SVN to Git?如何将 Maven 发布插件从 SVN 迁移到 Git?
【发布时间】:2017-12-31 18:24:44
【问题描述】:

我们正在将我们的项目从 SVN 迁移到 Git。我们使用 Maven 发布插件到 mvn release:preparemvn release:perform 我们的包。

除此之外,我们正在修改 pom.xml 文件的 scm 属性以指向我们的 git 存储库。

但是,当我们运行mvn release:prepare 时出现以下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.1:prepare (default-cli) on project MyProject: Unable to check for local modifications
[ERROR] Provider message:
[ERROR] The svn command failed.
[ERROR] Command output:
[ERROR] 'svn' is not recognized as an internal or external command,
[ERROR] operable program or batch file.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

为什么它还在尝试执行 cmd.exe /X /C "svn --non-interactive status" ? 还需要配置什么才能在此发布过程中完全迁移?

我的 pom.xml 上下文详细信息:

<scm>
    <connection>scm:git:https://myGitProjectUrl.git</connection>
    <developerConnection>scm:git:https://myGitProjectUrl.git</developerConnection>
    <url>https://myGitProjectUrl</url>
</scm>
...
<build>
    <plugins>
        <!-- Maven Release Plugin -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <goals>deploy</goals>
            </configuration>
        </plugin>

【问题讨论】:

  • 您能否确认您是否在正确的 git 项目和带有 git scm URL 的 pom 文件中?
  • @RishikeshDarandale,好问题。是的,我现在已经检查了三次以确保。我从包含 pom.xml 的本地文件夹中运行命令,该文件夹是正确的项目并且匹配适当的 git repo。
  • 嗯,一切看起来都不错。能否请您尝试将插件版本更新为2.5.3
  • 请在 pluginManagement 中定义 maven-release-plugin 而不仅仅是您所做的...除此之外,您是否尝试从命令行或像 Jenkins 这样的 CI 解决方案调用它?在 Windows/Linux 上工作?请显示运行的完整日志输出......是的顺便说一句。尝试使用 2.5.3 的 maven-release-plugin...
  • @user944849 我刚刚确认此项目中没有其他 pom.xml 文件声明了 scm 属性。唯一的包含在父 pom 中,它们都引用了 git repos。

标签: git maven maven-release-plugin


【解决方案1】:

你可以在plugin 下尝试maven-invoker 依赖:

 <build>
    <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.5.1</version>
          <dependencies>
            <dependency>
              <groupId>org.apache.maven.shared</groupId>
              <artifactId>maven-invoker</artifactId>
              <version>2.2</version>
            </dependency>
          </dependencies>
        </plugin>
    </plugins>

【讨论】:

  • 依赖已经是 maven-release-plugin 的一部分,不需要再次定义它......
猜你喜欢
  • 1970-01-01
  • 2021-05-03
  • 2017-08-02
  • 2015-07-11
  • 2011-02-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-06
相关资源
最近更新 更多