Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using maven-release-plugin with git-1.8.5

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] 
like image 664
yegeniy Avatar asked Jan 03 '14 20:01

yegeniy


2 Answers

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.
like image 95
yegeniy Avatar answered Oct 23 '22 06:10

yegeniy


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

like image 25
Joey Coleman Avatar answered Oct 23 '22 05:10

Joey Coleman