我正在尝试让我的Maven项目在Windows 7和Ubuntu 13.04上工作。在pom.xml文件中,我使用maven-antrun-plugin来调用scons,我已经在我的Linux和Windows机器上安装了它。在两个操作系统上,我都验证过可以从shell/cmd运行scons
,因此它在PATH上。pom文件如下:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>run-scons</id>
<phase>generate-resources</phase>
<configuration>
<target name="run-scons">
<exec executable="scons" dir="${basedir}/../../../" failonerror="true">
<arg value="-j4" />
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
但是当我在Windows 7上构建时,我会得到以下错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (run-scons) on project my-project: An Ant BuildExcept
ion has occured: Execute failed: java.io.IOException: Cannot run program "scons" (in directory "C:\Users\u\samples"): CreateProcess error=2,
The system cannot find the file specified
[ERROR] around Ant part ...<exec dir="C:\Users\u\samples...." executable="scons" failonerror="true">
如果我在cmd中打开并运行它,我会得到:
C:\Users\u\samples\>scons
scons: Reading SConscript files ...
Using configuration: scons/win32mscdbg.py
为什么我不能从antrun插件中调用scons?如果我在Windows上指定scons的完整路径,它可以工作(例如:C:\Python26\Scripts\scons.bat),但这是不可行的,因为开发人员只需要将scons添加至其路径即可,并可以自行决定其位置。