检查可执行命令存在使用蚂蚁
时可以检查是否存在命令,作为蚂蚁任务的一部分。例如,我要保证YASM命令present作为蚂蚁任务的一部分。这可能吗?如果是这样,你可以提供一个例子吗?
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?
我能想到的要做到这一点,最好的办法是使用可用
任务与联合如果
在随后的目标。如果你看一看这任务页面你会看到,你可以检查看看是否有存在,那么设置一个属性。例如:
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"/>
然后在目标你会说像&LT ;目标名称='富',如果='文件present。'&GT;
这并不检查可执行的权限,但它会变得更加接近。如果一个任务存在检查可执行权限具体情况,你可能仍然与如果
目标结合起来。
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.
原来的答案
Original answer
这是更好地使用,而不是试图执行 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文档更多的使用。
More usage on the Ant documentation for the copy task.