<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 72, comments - 66, trackbacks - 0, articles - 0

    ant 條件判斷 condition

    Posted on 2008-05-21 15:26 Fingki.li 閱讀(10636) 評論(0)  編輯  收藏 所屬分類: About development
    最近收到一個ticket,用ant寫個build.xml,用到condition,作筆記如下:

        basic elements: istrue isfalse not and or xor available isset equals  filesmatch
        1、istrue isfalse:斷言 真 假
    <project name="testCondition">
        <target name="test">
            <condition property="scondition">
                <istrue value="true"/>                   
            </condition>
            <antcall target="isTrue"></antcall>
            <antcall target="isFalse"></antcall>       
        </target>
        <target name="isTrue" if="scondition">
            <echo>is ture</echo>
        </target>
        <target name="isFalse" unless="scondition">
            <echo>is false</echo>
        </target>
    </project>

        2、邏輯運算
        2.1、not 邏輯非 
    <project name="testCondition">
        <target name="test">
            <condition property="scondition">
                <not>
                    <istrue value="true"/>                   
                </not>
            </condition>
            <antcall target="isTrue"></antcall>
            <antcall target="isFalse"></antcall>       
        </target>
        <target name="isTrue" if="scondition">
            <echo>is ture</echo>
        </target>
        <target name="isFalse" unless="scondition">
            <echo>is false</echo>
        </target>
    </project>
        2.2、and 邏輯與
    <project name="testCondition">
        <target name="test">
            <condition property="scondition">
                <and>
                    <istrue value="true"/>
                    <istrue value="false"/>                   
                </and>
            </condition>
            <antcall target="isTrue"></antcall>
            <antcall target="isFalse"></antcall>       
        </target>
        <target name="isTrue" if="scondition">
            <echo>is ture</echo>
        </target>
        <target name="isFalse" unless="scondition">
            <echo>is false</echo>
        </target>
    </project>
        2.3、or 邏輯或 xor異或 (語法上與and類似)

        3、available 是否可用
    <project name="testCondition">
        <path id="all.test.classes">        
             <pathelement location="bin"/>
         </path>
        <target name="test">
            <condition property="scondition">
                <!--在指定的classpath路徑下是否存在資源 TestTest.class-->
                <available resource="TestTest.class">
                    <classpath refid="all.test.classes" />       
                </available>
            </condition>
            <antcall target="isTrue"></antcall>
            <antcall target="isFalse"></antcall>       
        </target>
        <target name="isTrue" if="scondition">
            <echo>is ture</echo>
        </target>
        <target name="isFalse" unless="scondition">
            <echo>is false</echo>
        </target>
    </project>

        4、isset 指定屬性是否存在
    <project name="testCondition">
        <!--屬性也可以通過ant參數-D來設置-->
        <property name="name" value="this is name"/>   
        <target name="test">
            <condition property="scondition">
                <!--如果屬性name不存在則返回false-->
                <isset property="name"/>
            </condition>
            <antcall target="isTrue"></antcall>
            <antcall target="isFalse"></antcall>       
        </target>
        <target name="isTrue" if="scondition">
            <echo>is ture</echo>
        </target>
        <target name="isFalse" unless="scondition">
            <echo>is false</echo>
        </target>
    </project>
        5、equals 是否相等
    <project name="testCondition">
        <!--屬性也可以通過ant參數-D來設置-->
        <property name="name" value="this is name"/>   
        <target name="test">
            <condition property="scondition">
                <!--如果arg1的值與arg2的值相等返回true,否則為false-->
                <equals arg1="${name}" arg2="this is name"/>
            </condition>
            <antcall target="isTrue"></antcall>
            <antcall target="isFalse"></antcall>       
        </target>
        <target name="isTrue" if="scondition">
            <echo>is ture</echo>
        </target>
        <target name="isFalse" unless="scondition">
            <echo>is false</echo>
        </target>
    </project>   
        6、filesmatch 比較文件
    <project name="testCondition">       
        <target name="test">
            <condition property="scondition">
                <!--如果file1所代表的文件與file2所代表的文件相等返回true,否則為false-->
                <filesmatch file1="testfile1.txt" file2="testfile2.txt"/>
            </condition>
            <antcall target="isTrue"></antcall>
            <antcall target="isFalse"></antcall>       
        </target>
        <target name="isTrue" if="scondition">
            <echo>is ture</echo>
        </target>
        <target name="isFalse" unless="scondition">
            <echo>is false</echo>
        </target>
    </project>   


    更多內容可以參考:http://ant.apache.org/manual/CoreTasks/conditions.html
    主站蜘蛛池模板: 国产午夜亚洲精品不卡电影| 亚洲国产精品xo在线观看| 亚洲精品色在线网站| 国产卡二卡三卡四卡免费网址| 久久久亚洲欧洲日产国码二区| 日韩视频在线观看免费| 亚洲av中文无码乱人伦在线播放| 少妇性饥渴无码A区免费 | 四虎免费久久影院| 久久精品国产亚洲AV天海翼 | 四虎永久在线精品免费网址 | 亚洲娇小性xxxx色| 女人18特级一级毛片免费视频| 日韩亚洲产在线观看| 国产乱子伦精品免费无码专区 | 午夜视频免费成人| 无遮挡呻吟娇喘视频免费播放| 亚洲人成色7777在线观看| 久久久久久AV无码免费网站 | 四虎成人免费观看在线网址 | 日韩精品无码永久免费网站| 亚洲日韩在线第一页| 久久久久免费精品国产| 亚洲国产午夜精品理论片| 四色在线精品免费观看| 中文字幕免费人成乱码中国| 亚洲综合一区二区精品导航| 好爽…又高潮了免费毛片| 日韩在线一区二区三区免费视频| 亚洲国产精品VA在线观看麻豆| 无码国产精品一区二区免费虚拟VR | 国产高潮久久免费观看| 久久精品7亚洲午夜a| 成年丰满熟妇午夜免费视频| 三年片在线观看免费观看大全中国 | 亚洲精品无码aⅴ中文字幕蜜桃| 亚洲精品国产自在久久| 1000部无遮挡拍拍拍免费视频观看| 亚洲av无码一区二区三区四区| 久久亚洲色一区二区三区| 美女视频黄免费亚洲|