<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
    主站蜘蛛池模板: 中文字幕版免费电影网站| 日本在线观看免费高清| 最近中文字幕mv免费高清视频8| 亚洲国产另类久久久精品小说| 国产在线观看xxxx免费| 好看的电影网站亚洲一区| 久久免费美女视频| 亚洲综合婷婷久久| 18禁免费无码无遮挡不卡网站| 亚洲特级aaaaaa毛片| 丁香花免费完整高清观看| 亚洲精品123区在线观看| 在线播放高清国语自产拍免费| 国产成人精品久久亚洲高清不卡 | 国产精品亚洲精品日韩已方| 日韩大片免费观看视频播放| 亚洲日本一区二区三区在线不卡| 国产成人无码免费看片软件 | 国产免费AV片在线观看播放| 亚洲精品乱码久久久久久| 性无码免费一区二区三区在线| 亚洲国产成人综合| 在线观看成人免费视频| 国产精品黄页免费高清在线观看| 亚洲精品乱码久久久久久中文字幕 | 亚洲乱码无人区卡1卡2卡3| 免费乱码中文字幕网站| 波多野结衣免费一区视频 | 亚洲av不卡一区二区三区| 综合在线免费视频| 在线亚洲精品视频| 国产成人亚洲综合无码精品 | 国产亚洲色视频在线| 亚洲美女免费视频| 亚洲AV无码资源在线观看| 亚洲综合av永久无码精品一区二区| 亚洲视频在线观看免费| 中日韩亚洲人成无码网站| 中文字幕专区在线亚洲| 99在线视频免费观看视频 | 亚洲av成人中文无码专区|