使用ant检查可执行命令是否存在 [英] Check if executable command exists using ant

查看:28
本文介绍了使用ant检查可执行命令是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以检查命令是否作为 ant 任务的一部分存在.例如,我想确保yasm"命令作为 ant 任务的一部分出现.这可能吗?如果是这样,你能举个例子吗?

Is it possible to check if a command exists as part of an ant task. For example, I want to ensure the "yasm" command is present as part of the ant task. Is this possible? If so, can you provide an example?

推荐答案

我能想到的最好方法是将 available 任务与 if 在随后的目标中.如果您查看该任务页面,您将看到您可以查看查看是否存在某些内容,然后设置一个属性.例如:

The best way I can think of to do this is by using the available task combined with an if in a subsequent target. If you take a look at that task page you will see that you can check to see if something exists then set a property. For example:

<available file="/path/to/my/file" type="file" property="file.present"/>

然后在 target 你会说类似 <target name='foo' if='file.present'>

Then in the target you would say something like <target name='foo' if='file.present'>

这不会检查可执行权限,但会更接近.如果存在专门检查可执行权限的任务,您仍然可能会将其与目标中的 if 结合起来.

That doesn't check for executable permissions but it will get much closer. If a task exists to check for the executable permission specifically you would still probably combine it with the if in the target.

<小时>原答案

最好使用ant copy任务,而不是自己尝试执行cp.这使其平台保持独立.

It is better to use the ant copy task instead of trying to execute cp yourself. This keeps its platform independent.

<copy todir"/some/target">
   <fileset dir="/some/src"/>
</copy>

有关复制任务的 Ant 文档的更多用法.

这篇关于使用ant检查可执行命令是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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