我的Ant脚本中有以下代码段.它执行得很好:
<exec executable="C:\test\foo\programName.exe" />
但是当我尝试通过设置目录来执行它时,如下所示:
<exec executable="programName.exe" dir="C:\test\foo\" />
我明白了:
Execute Failed: java.io.IOException:@H_403_12@ Cannot run program “programName.exe”@H_403_12@ (in directory “C:\test\foo”):@H_403_12@ CreateProcess error=2,The system@H_403_12@ cannot find the file specified
请帮忙!为什么单独指定目录时它不起作用?
解决方法
添加resolveexecutable属性:
<exec executable="programName.exe" resolveexecutable="true" dir="C:\test\foo\" />
resolveexecutable When this@H_403_12@ attribute is true,the name of the@H_403_12@ executable is resolved firstly against@H_403_12@ the project basedir and if that does@H_403_12@ not exist,against the execution@H_403_12@ directory if specified. On Unix@H_403_12@ systems,if you only want to allow@H_403_12@ execution of commands in the user’s@H_403_12@ path,set this to false. since Ant 1.6@H_403_12@ No,default is false