在Windows机器上使用Maven 3.0.5,我试图从Cygwin bash提示符运行mvn -X -B release:prepare
,该提示失败。这是一些输出:
[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位置使用正斜杠来提交命令?
编辑:
从源代码构建Maven,在Cygwin下本地。从具有两个子模块的原型创建了一个示例项目。使用与之前相同的结果重复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。的Bleh:
答案 0 :(得分:2)
我通过手动执行git命令解决了这个问题。
Maven消息说出它试图执行的内容,我手动执行了这个命令,纠正了斜杠。
然后我重新运行maven并获得了第二个git命令也将失败。
我也是手动完成的,最后一次重新运行maven。
这不好,但至少它是一个手动解决方法。
答案 1 :(得分: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>