有没有办法让 Ant 创建 shell 或批处理运行时脚本? [英] Is there a way to have Ant create a shell or batch runtime script?

查看:26
本文介绍了有没有办法让 Ant 创建 shell 或批处理运行时脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让 Ant 创建运行时 shell 或批处理运行时脚本,而不必自己手动创建脚本.

Is there a way to have Ant create a runtime shell or batch runtime script instead of having to manually create the script myself.

它类似于链接文本

推荐答案

是的,可以做到.这是一个简单的示例(您的链接现在无法正常工作...抛出 sourceforge 错误).基本思想是使用 echo 任务编写文件,然后使用exec 任务:

Yes it can be done. Here's a simple example (your link is not working right now ... sourceforge error thrown). The basic idea is to write the file using the echo task, then run it using the exec task:

<property name="myls" value="myls.sh" />
<echo file="${myls}">
ls
</echo>
<exec executable="sh">
    <arg value="${myls}"/>
</exec>

运行时给出以下内容,因为工作目录仅包含构建文件和脚本:

When run gives the following, as the working directory only contains the build file and the script:

Buildfile: build.xml
     [exec] build.xml
     [exec] myls.sh

这当然是特定于 unix 的,但您可以在其他系统上做类似的事情 - 对于 Windows,您可以将可执行文件更改为 cmd 我相信.如果需要,您可以更进一步,并将参数传递给新脚本.例如:

This is of course unix-specific, but you could do similar equally well on other systems - for windows you'd change the executable to cmd I believe. You can take this further and pass arguments to your new script too if needed. For example:

<property name="myls" value="myls.sh" />
<echo file="${myls}">
ls $@
</echo>
<exec executable="sh">
    <arg value="${myls}"/>
    <arg value="b*"/>
</exec>

现在运行时只看到构建文件:

When run now only sees the build file:

Buildfile: build.xml
     [exec] build.xml

这篇关于有没有办法让 Ant 创建 shell 或批处理运行时脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆