【发布时间】:2009-01-17 11:29:30
【问题描述】:
我想根据操作系统类型在 ant 任务中设置不同的属性。
该属性是一个目录,在 windows 中我希望它是 unix/linux "/opt/flag" 中的 "c:\flag"。
我当前的脚本仅在我使用默认目标运行时才有效,但为什么呢?
<target name="checksw_path" depends="if_windows, if_unix"/>
<target name="checkos">
<condition property="isWindows">
<os family="windows" />
</condition>
<condition property="isLinux">
<os family="unix" />
</condition>
</target>
<target name="if_windows" depends="checkos" if="isWindows">
<property name="sw.root" value="c:\flag" />
<echo message="${sw.root}"/>
</target>
<target name="if_unix" depends="checkos" if="isLinux">
<property name="sw.root" value="/opt/flag" />
<echo message="${sw.root}"/>
</target>
在我的所有 ant 目标中,我添加了一个“depends=checksw_path”。
如果我在 windows 中运行默认目标,我得到了正确的“c:\flag”,但是如果我运行一个非默认目标,我得到了调试进入 if_windows 但指令“”没有设置保留 /opt/flag 的属性。我正在使用 ant 1.7.1。
【问题讨论】:
标签: ant