exec-maven-plugin表示无法运行指定的程序,即使它位于PATH上 [英] exec-maven-plugin says cannot run specified program, even though it is on the PATH
问题描述
编辑20140716 :
tl; dr = exec-maven-plugin 不识别 .cmd
文件,但只有 .bat
文件,作为可执行脚本。重命名 grunt.cmd - > grunt.bat
, bower.cmd - > bower.bat
等作为解决方法。
tl;dr = exec-maven-plugin does not recognise .cmd
files, but only .bat
files, as executable scripts. Rename grunt.cmd --> grunt.bat
, bower.cmd --> bower.bat
, etc. as a workaround.
完成我的系统上的npm install -g grunt-cli
, grunt
肯定是在 PATH
当我运行 maven install
但是,这似乎没有注册。
When I run maven install
however, this doesn't seem to register.
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
(build-spa-bower) on project foobar: Command execution failed.
Cannot run program "grunt" (in directory "C:\workspace\foobar\src\main\spa"):
CreateProcess error=2, The system cannot find the file specified -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException:
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
(build-spa-bower) on project foobar: Command execution failed.
为了确保,在同一个终端,我执行了这个
Just to be sure, in the same terminal, I have executed this
cd C:\workspace\foobar\src\main\spa
grunt build
...在我发出上面的maven命令的同一个终端中,grunt执行得很好。
... in the same terminal as I issued the maven command above, and grunt executes just fine.
exec-maven-plugin
使用 PATH
环境变量,还是需要告诉我这个可执行文件有其他方式吗?
Does exec-maven-plugin
use the PATH
environment variable, or does it need to be told that this executable exisst in some other way?
这文档表明 PATH <上的可执行文件应该找到/ code>,所以它让我更进一步。
This documentation suggests that executables on PATH
should be found, so it stumps me further.
推荐答案
除了bguiz的答案,哪个会是最好的解决方案,我已经使用Maven配置文件创建了一个解决方法,绕过了这个问题。
In addition to bguiz' answer, which would be the best solution, I've created a workaround using Maven profiles, bypassing the problem.
这是一个临时解决方案直到maven-exec-plugin的bug被修复为止。
This is a temporary solution, until the maven-exec-plugin's bug gets fixed.
请在此处上传错误报告: http://jira.codehaus.org/browse/MEXEC-118
Please upvote the bug report here: http://jira.codehaus.org/browse/MEXEC-118
编辑:该错误已解决,您可以指向1.4-SNAPSHOT进行修复。
The bug is resolved, you can point to 1.4-SNAPSHOT to fix it.
<project>
(...)
<profiles>
<profile>
<id>grunt-exec-windows</id>
<activation>
<os>
<family>Windows</family>
</os>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec-maven-plugin.version}</version>
<executions>
<execution>
<id>grunt-default</id>
<phase>generate-resources</phase>
<configuration>
<executable>cmd</executable>
<arguments>
<argument>/C</argument>
<argument>grunt</argument>
</arguments>
</configuration>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
这篇关于exec-maven-plugin表示无法运行指定的程序,即使它位于PATH上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!