Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a Maven release to work with git?

Trying to release, I always get this:

[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Unable to commit files
Provider message:
The git-commit command failed.
Command output:

There is nothing by "command output".

Is there some secret configuration trick to get maven to play nice with git?

like image 448
willCode4Beer Avatar asked Mar 25 '11 22:03

willCode4Beer


People also ask

How does Maven release work?

Performing the release. The plugin will extract file revisions associated with the current release. Maven will compile, test and package the versioned project source code into an artifact. The final deliverable will then be released into an appropriate maven repository.

Does Maven use Git?

GIT holds the sourcecode of your application. MAVEN is used for dependency management. It holds the binary dependecies of your application. It also creates a abstraction of the used IDE.

What is Maven SCM plugin?

The SCM Plugin offers vendor independent access to common scm commands by offering a set of command mappings for the configured scm. Each command is implemented as a goal.


2 Answers

The only case I saw where the git-commit command output was empty was on issue 556, where the following solution was proposed:

I had exactly the same problem as you; and:

  • removing the release.properties and
  • putting back my pom version to a SNAPSHOT (it was previously changed by the plugin) version

resolved the problem; the process ended successfully.

like image 81
VonC Avatar answered Sep 22 '22 19:09

VonC


Like it's being said in the other answer, restoring is done either by doing

mvn release:clean

but since this doesn't always work, so the solution would be to remove release.properties, and running

mvn versions:set -DnewVersion={version with snapshot}

(This is not necessary if you reset your git repostiory to the state prior to running the release plugin.)

You might also have to remove the commits made by the release plugin, with

git reset --hard HEAD~1

It usually makes two commits, to remove both either run the above command twice, or change the ~1 with ~2.

To decouple the git stuff from the maven stuff (so that the mvn build doesn't break upon a git error, you could add this to your pom.xml:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <configuration>
        <pushChanges>false</pushChanges>
    </configuration>
</plugin>

Setting push-changes to false lets you control the git push yourself. (Remember that you also have to push tags, git push --tags.

like image 27
Tobb Avatar answered Sep 18 '22 19:09

Tobb