如何让 Maven 版本与 git 一起使用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5438710/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get a Maven release to work with git?
提问by willCode4Beer
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?
是否有一些秘密的配置技巧可以让 maven 与 git 一起玩得很好?
回答by VonC
The only case I saw where the git-commit command output was empty was on issue 556, where the following solution was proposed:
我看到 git-commit 命令输出为空的唯一情况是问题 556,其中提出了以下解决方案:
I had exactly the same problem as you; and:
- removing the
release.properties
and- putting back my
pom
version to aSNAPSHOT
(it was previously changed by the plugin) versionresolved the problem; the process ended successfully.
我和你有完全一样的问题;和:
- 删除
release.properties
和- 将我的
pom
版本放回SNAPSHOT
(之前已被插件更改)版本解决了问题;该过程成功结束。
回答by Tobb
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
但由于这并不总是有效,所以解决方案是删除release.properties
并运行
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.)
(如果您将 git 存储库重置为运行发布插件之前的状态,则不需要这样做。)
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
.
它通常会进行两次提交,以删除两者,或者运行上述命令两次,或者更改~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
:
要将 git 内容与 maven 内容分离(以便 mvn 构建不会因 git 错误而中断,您可以将其添加到您的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
.
将 push-changes 设置为 false 可以让您自己控制 git push。(请记住,您还必须推送标签,git push --tags
.
回答by ihadanny
Had the exact same problem and both solutions here did not work, until I upgraded from mvn-3.0.4
to mvn 3.2.5
遇到了完全相同的问题,这里的两个解决方案都不起作用,直到我从 升级mvn-3.0.4
到mvn 3.2.5