`

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>
 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics