如何让 Maven 版本与 git 一起使用?

发布于 2024-10-26 21:39:23 字数 392 浏览 3 评论 0原文

尝试发布时,我总是得到这样的信息:

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

“命令输出”没有任何内容。

是否有一些秘密配置技巧可以让 Maven 与 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

何必那么矫情 2024-11-02 21:39:24

我看到 git-commit 命令输出为空的唯一情况是 问题 556,其中提出了以下解决方案:

我遇到了和你完全相同的问题;和:

  • 删除release.properties
  • 将我的 pom 版本恢复为 SNAPSHOT(之前已被插件更改)版本

解决了问题;该过程成功结束。

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.

深海少女心 2024-11-02 21:39:24

就像另一个答案中所说的那样,恢复可以通过以下方式完成

mvn release:clean

,但由于这并不总是有效,因此解决方案是删除 release.properties 并运行

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

(如果您将 git 存储库重置为运行发布插件之前的状态。)

您可能还需要删除发布插件所做的提交,

git reset --hard HEAD~1

它通常会进行两次提交,要删除两者,请运行上述命令两次,或更改~1~2

要将 git 内容与 maven 内容解耦(以便 mvn 构建不会因 git 错误而中断,您可以将其添加到您的 pom.xml 中:

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

将 Push-changes 设置为 false 可以让您控制git 自己推送(请记住,您还必须推送标签,git push --tags

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.

傲影 2024-11-02 21:39:24

遇到完全相同的问题,这里的两种解决方案都不起作用,直到我从 mvn-3.0.4 升级到 mvn 3.2.5

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文