Using maven-release-plugin with git-1.8.5

↘锁芯ラ 提交于 2019-12-10 14:59:58

问题


When using git-1.8.5, with maven-release-plugin (tested with versions 2.4.2 and 2.3.2) with mvn (tested with versions 3.1.1 and 3.0.5), running mvn release:prepare and mvn release:prepare-with-pom fails.

mvn release:prepare fails to create the commits that it's supposed to create:

[maven-release-plugin] prepare for next development iteration
[maven-release-plugin] prepare release foo-1.0.0

and mvn release:prepare-with-pom fails with a git error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.4.2:prepare-with-pom (default-cli) on project foo: Cannot remove release POMs from SCM
[ERROR] Provider message:
[ERROR] The git command failed.
[ERROR] Command output:
[ERROR] error: the following file has changes staged in the index:
[ERROR] release-pom.xml
[ERROR] (use --cached to keep the file, or -f to force removal)
[ERROR] -> [Help 1]
[ERROR] 

回答1:


This appears to have been fixed in version 2.5 of maven-release-plugin, which was released on March 5th.




回答2:


As per Mark Derricutt's solution, explicitly add the maven-scm-provider-gitexe:1.8.1 dependency to the maven-release-plugin:2.4.2 plugin:

<build>
   <plugins>
      <!-- ... -->
      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-release-plugin</artifactId>
         <version>2.4.2</version>
         <dependencies>
            <dependency>
               <groupId>org.apache.maven.scm</groupId>
               <artifactId>maven-scm-provider-gitexe</artifactId>
               <!-- This version is necessary for use with git version 1.8.5 -->
               <version>1.8.1</version>
            </dependency>
         </dependencies>
      </plugin>
   </plugins>
</build>

Background:

  • git-1.8.5 introduced a breaking change to the format of git status, so now scripts like maven-release-plugin should use the porcelain option git status --porcelain instead of git status.
  • Therefore, Robert Scholte could not include a dependency to maven-scm-provider-gitexe:1.8 with maven-release-plugin:2.4.2.
  • the maven scm provider for git incorporates the fix to include the --porcelain flag with maven-scm-provider-gitexe:1.8.1, but maven-release-plugin:2.4.2 does not have its dependency for maven-scm-provider-gitexe updated yet. See https://jira.codehaus.org/browse/SCM-686 for more info.
  • Despite the outdated dependency, we can overwrite it by adding the dependency to 1.8.1 explicitly as shown above.


来源:https://stackoverflow.com/questions/20912299/using-maven-release-plugin-with-git-1-8-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!