我可以在Ant复制任务操作系统的具体情况? [英] Can I make the Ant copy task OS-specific?
本文介绍了我可以在Ant复制任务操作系统的具体情况?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有执行使用复制任务复制操作的Ant脚本。它是为Windows编写的,并具有硬codeD C:\\路径为todir的说法。我看到了'EXEC'任务都有一个操作系统的说法,有没有类似的方式进行分支基于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屋!
查看全文