5

在 Windows 机器上使用 Maven 3.0.5,我试图mvn -X -B release:prepare从 Cygwin bash 提示符运行,但失败了。这是一些输出:

[INFO] Executing: cmd.exe /X /C "git commit --verbose -F C:\cygwin\tmp\maven-scm-24643703.commit pom.xml module1\pom.xml module2\pom.xml"

...

[ERROR] The git-commit command failed.
[ERROR] Command output:
[ERROR] error: pathspec '"module1\\pom.xml"' did not match any file(s) known to git.
[ERROR] error: pathspec '"module2\\pom.xml"' did not match any file(s) known to git.

如果我在将反斜杠修改为正斜杠之后手动运行命令(从 bash 提示符),它可以工作:

cmd.exe /X /C "git commit --verbose pom.xml module1/pom.xml module2/pom.xml"

我尝试修改根 pom 以使其自动发生:

<properties>
    <file.separator>/</file.separator>
    <fileSeparator>/</fileSeparator>
</properties>

我在命令行上尝试了各种选项:

-Darguments="-DfileSeparator=/"
-Darguments="-Dfile.separator=/"
-DfileSeparator='/'

有没有办法指示 Maven 在提交命令的子模块 pom 位置中使用正斜杠?

编辑:

在 Cygwin 下本地从源代码构建 Maven。从具有两个子模块的原型创建示例项目。重复了mvn -B release:prepare与以前相同的结果:

[INFO] [INFO] BUILD SUCCESS
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 3.316s
[INFO] [INFO] Finished at: Fri Jun 28 14:29:53 CDT 2013
[INFO] [INFO] Final Memory: 19M/223M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] Checking in modified POMs...
[INFO] Executing: cmd.exe /X /C "git add -- pom.xml module1\pom.xml module2\pom.xml"
[INFO] Working directory: C:\cygwin\home\don.branson\projects\example
[INFO] Executing: cmd.exe /X /C "git status"
[INFO] Working directory: C:\cygwin\home\don.branson\projects\example
[INFO] Executing: cmd.exe /X /C "git commit --verbose -F C:\cygwin\tmp\maven-scm-1306363489.commit pom.xml module1\pom.xml
module2\pom.xml"
[INFO] Working directory: C:\cygwin\home\don.branson\projects\example
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] example ........................................... FAILURE [6.972s]
[INFO] module1 ........................................... SKIPPED
[INFO] module2 ........................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.475s
[INFO] Finished at: Fri Jun 28 14:29:54 CDT 2013
[INFO] Final Memory: 8M/153M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.0:prepare (default-cli) on project example:
Unable to commit files
[ERROR] Provider message:
[ERROR] The git-commit command failed.
[ERROR] Command output:
[ERROR] error: pathspec '"module1\\pom.xml"' did not match any file(s) known to git.
[ERROR] error: pathspec '"module2\\pom.xml"' did not match any file(s) known to git.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

这是根 pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.example</groupId>
  <artifactId>example</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>pom</packaging>

  <name>example</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <scm>
    <connection>scm:git:file://../example.git/</connection>
  </scm>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <modules>
    <module>module1</module>
    <module>module2</module>
  </modules>
</project>

这是module1的pom.xml:

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.example</groupId>
    <artifactId>example</artifactId>
    <version>1.0-SNAPSHOT</version>
  </parent>
  <groupId>com.example</groupId>
  <artifactId>module1</artifactId>
  <version>1.0-SNAPSHOT</version>
  <name>module1</name>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

编辑:

这是一个有同样问题的人。他的解决方案是使用 windows shell 而不是 bash。呼:

http://www.theroundmeatball.com/making-maven-release-plugin-on-windows-with-git-gpg-and-github-to-work/

4

2 回答 2

2

我通过手动执行 git 命令来解决它。

Maven 消息说明了它试图执行的内容,我手动执行了这个命令,更正了斜杠。

然后我重新运行 maven 并得到第二个也会失败的 git 命令。

我也手动执行此操作并最后一次重新运行 maven。

这不是很好,但至少它是一种手动解决方法。

于 2014-02-07T11:42:58.597 回答
1

我自己也遇到过这个。即使是最新的 2.5.3 版本插件也有这个问题。我的解决方法是从https://git-scm.com/download/win下载 Portable Git并将其放在..../PortableGit/cmd路径的第一位。这有效地用 windows 版本替换了 cygwin git。在pom.xml我明确要求 2.5.3 插件:

           <plugin>
                   <groupId>org.apache.maven.plugins</groupId>
                   <artifactId>maven-release-plugin</artifactId>
                   <version>2.5.3</version>
           </plugin>
于 2016-03-07T14:24:50.850 回答