Ant -- condition task

Ant的 condition task 用于条件判断,如果condition为true, 那么设置property的值,否则不设置property的值。

实例:
1. 如果classpath中同时有 B和C , 那么设置property a:
<condition property="a">
<and> //当and内部的所有条件都是真的时候,它才为真;
<available classname="B"/>//classpath有class B的时候为真;
<available classname="C"/>
</and>
</condition>

2. 设置property a, 如果当前操作系统是MacOS,并且不是MacOS X
<condition property="a">
<and>
<os family="mac"/> //os family的名字为mac

<not>// 表示非
<os family="unix"/>

</not>
</and>
</condition>
注:常用的os family 有如下
windows (for all versions of Microsoft Windows)
dos (for all Microsoft DOS based operating systems including Microsoft Windows and OS/2)
mac (for all Apple Macintosh systems)
unix (for all Unix and Unix-like operating systems)
netware (for Novell NetWare)
os/2 (for OS/2)
tandem (for HP's NonStop Kernel - formerly Tandem)
win9x for Microsoft Windows 95 and 98, ME and CE
winnt for Microsoft Windows NT-based systems, including Windows 2000, XP and successors
z/os for z/OS and OS/390
os/400 for OS/400
openvms for OpenVMS

3. 设置property a , 当os的名字是SunOS,并且风格是sparc的时候。
<condition property="a">
<os name="SunOS" arch="sparc"/>

</condition>

4.
<condition property="scondition">
<istrue value="true"/> //判定字符串"true”是否为
//"true","yes", or "on"中的一个值,是的话就为true。
</condition>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值