在 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。呼: