zoukankan      html  css  js  c++  java
  • ant的condition任务

     1、istrue isfalse:断言 真 假


    Xml代码
    1. <project name="testCondition">  
    2.     <target name="test">  
    3.         <condition property="scondition">  
    4.             <istrue value="true"/>                      
    5.         </condition>  
    6.         <antcall target="isTrue"></antcall>  
    7.         <antcall target="isFalse"></antcall>          
    8.     </target>  
    9.     <target name="isTrue" if="scondition">  
    10.         <echo>is ture</echo>  
    11.     </target>  
    12.     <target name="isFalse" unless="scondition">  
    13.         <echo>is false</echo>  
    14.     </target>  
    15. </project>  

     

    2、逻辑运算


    2.1、not 逻辑非 

    Xml代码
    1. <project name="testCondition"  default="test">  
    2.     <target name="test">  
    3.         <condition property="scondition">  
    4.             <not>  
    5.                 <istrue value="true"/>                      
    6.             </not>  
    7.         </condition>  
    8.         <antcall target="isTrue"></antcall>  
    9.         <antcall target="isFalse"></antcall>          
    10.     </target>  
    11.     <target name="isTrue" if="scondition">  
    12.         <echo>is ture</echo>  
    13.     </target>  
    14.     <target name="isFalse" unless="scondition">  
    15.         <echo>is false</echo>  
    16.     </target>  
    17. </project>  

      

    2.2、and 逻辑与


    Xml代码
    1. <project name="testCondition" default="test">  
    2.     <target name="test">  
    3.         <condition property="scondition">  
    4.             <and>  
    5.                 <istrue value="true"/>  
    6.                 <istrue value="false"/>                      
    7.             </and>  
    8.         </condition>  
    9.         <antcall target="isTrue"></antcall>  
    10.         <antcall target="isFalse"></antcall>          
    11.     </target>  
    12.     <target name="isTrue" if="scondition">  
    13.         <echo>is ture</echo>  
    14.     </target>  
    15.     <target name="isFalse" unless="scondition">  
    16.         <echo>is false</echo>  
    17.     </target>  
    18. </project>  


    2.3、or 逻辑或 xor异或 (语法上与and类似)


    3、available 是否可用


    Xml代码  收藏代码
    1. <project name="testCondition" default="test">  
    2.     <path id="all.test.classes">           
    3.          <pathelement location="bin"/>  
    4.      </path>  
    5.     <target name="test">  
    6.         <condition property="scondition">  
    7.             <!--在指定的classpath路径下是否存在资源 TestTest.class-->  
    8.             <available resource="TestTest.class">  
    9.                 <classpath refid="all.test.classes" />          
    10.             </available>  
    11.         </condition>  
    12.         <antcall target="isTrue"></antcall>  
    13.         <antcall target="isFalse"></antcall>          
    14.     </target>  
    15.     <target name="isTrue" if="scondition">  
    16.         <echo>is ture</echo>  
    17.     </target>  
    18.     <target name="isFalse" unless="scondition">  
    19.         <echo>is false</echo>  
    20.     </target>  
    21. </project>  


    4、isset 指定属性是否存在


    Xml代码
    1. <project name="testCondition" default="test">  
    2.     <!--属性也能够通过ant參数-D来设置-->  
    3.     <property name="name" value="this is name"/>      
    4.     <target name="test">  
    5.         <condition property="scondition">  
    6.             <!--假设属性name不存在则返回false-->  
    7.             <isset property="name"/>  
    8.         </condition>  
    9.         <antcall target="isTrue"></antcall>  
    10.         <antcall target="isFalse"></antcall>          
    11.     </target>  
    12.     <target name="isTrue" if="scondition">  
    13.         <echo>is ture</echo>  
    14.     </target>  
    15.     <target name="isFalse" unless="scondition">  
    16.         <echo>is false</echo>  
    17.     </target>  
    18. </project>  

     

    5、equals 是否相等


    Xml代码  
    1. <project name="testCondition">  
    2.     <!--属性也能够通过ant參数-D来设置-->  
    3.     <property name="name" value="this is name"/>      
    4.     <target name="test">  
    5.         <condition property="scondition">  
    6.             <!--假设arg1的值与arg2的值相等返回true,否则为false-->  
    7.             <equals arg1="${name}" arg2="this is name"/>  
    8.         </condition>  
    9.         <antcall target="isTrue"></antcall>  
    10.         <antcall target="isFalse"></antcall>          
    11.     </target>  
    12.     <target name="isTrue" if="scondition">  
    13.         <echo>is ture</echo>  
    14.     </target>  
    15.     <target name="isFalse" unless="scondition">  
    16.         <echo>is false</echo>  
    17.     </target>  
    18. </project>    

     

    6、filesmatch 比較文件


    Xml代码
    1. <project name="testCondition">          
    2.     <target name="test">  
    3.         <condition property="scondition">  
    4.             <!--假设file1所代表的文件与file2所代表的文件相等返回true,否则为false-->  
    5.             <filesmatch file1="testfile1.txt" file2="testfile2.txt"/>  
    6.         </condition>  
    7.         <antcall target="isTrue"></antcall>  
    8.         <antcall target="isFalse"></antcall>          
    9.     </target>  
    10.     <target name="isTrue" if="scondition">  
    11.         <echo>is ture</echo>  
    12.     </target>  
    13.     <target name="isFalse" unless="scondition">  
    14.         <echo>is false</echo>  
    15.     </target>  
    16. </project>   
  • 相关阅读:
    MySQL运维案例分析:Binlog中的时间戳
    身边有位“别人家的程序员”是什么样的体验?
    苹果收取30%过路费_你是顶是踩?
    1019 数字黑洞 (20 分)C语言
    1015 德才论 (25 分)C语言
    1017 A除以B (20 分)C语言
    1014 福尔摩斯的约会 (20 分)
    求n以内最大的k个素数以及它们的和、数组元素循环右移问题、求最大值及其下标、将数组中的数逆序存放、矩阵运算
    1005 继续(3n+1)猜想 (25 分)
    爬动的蠕虫、二进制的前导的零、求组合数、Have Fun with Numbers、近似求PI
  • 原文地址:https://www.cnblogs.com/gcczhongduan/p/4306880.html
Copyright © 2011-2022 走看看