`
zhangjijun
  • 浏览: 33479 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

使用ant 的exec时不能随意省略可执行文件的扩展名

 
阅读更多

我原来这样写:

<exec dir="${another.project}" executable="ant">
  </exec>

结果:Execute failed: java.io.IOException: CreateProcess: ant error=2 

 

后来把 executable="ant" 改成 executable="ant.bat" 就成功了

官方文档这样说:

Windows Users

The <exec> task delegates to Runtime.exec which in turn apparently calls ::CreateProcess. It is the latter Win32 function that defines the exact semantics of the call. In particular, if you do not put a file extension on the executable, only ".EXE" files are looked for, not ".COM", ".CMD" or other file types listed in the environment variable PATHEXT. That is only used by the shell.

Note that .bat files cannot in general by executed directly. One normally needs to execute the command shell executable cmd using the /c switch.

<target name="help">
  <exec executable="cmd">
    <arg value="/c"/>
    <arg value="ant.bat"/>
    <arg value="-p"/>
  </exec>
</target>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics