我可以使 Ant 复制任务特定于操作系统吗? [英] Can I make the Ant copy task OS-specific?

查看:26
本文介绍了我可以使 Ant 复制任务特定于操作系统吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Ant 脚本,它使用 'copy' 任务执行复制操作.它是为 Windows 编写的,并且有一个硬编码的 C:\ 路径作为 'todir' 参数.我看到 'exec' 任务有一个 OS 参数,是否有类似的方法可以基于 OS 分支副本?

I have an Ant script that performs a copy operation using the 'copy' task. It was written for Windows, and has a hardcoded C:\ path as the 'todir' argument. I see the 'exec' task has an OS argument, is there a similar way to branch a copy based on OS?

推荐答案

我建议将路径放在一个属性中,然后根据当前操作系统有条件地设置该属性.

I would recommend putting the path in a property, then setting the property conditionally based on the current OS.

<condition property="foo.path" value="C:\Foo\Dir">
   <os family="windows"/>
</condition>
<condition property="foo.path" value="/home/foo/dir">
   <os family="unix"/>
</condition>

<fail unless="foo.path">No foo.path set for this OS!</fail>

作为附带的好处,一旦它位于属性中,您就可以在不编辑 Ant 脚本的情况下覆盖它.

As a side benefit, once it is in a property you can override it without editing the Ant script.

这篇关于我可以使 Ant 复制任务特定于操作系统吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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