国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
ant 中 if else - 學習筆記

ant中的條件判斷實例:

ant中條件判斷這里有2種形式,一種是運用 target 的if and unless attributes,一種是運用ant-contrib中的if else。

第一種:
<project name="test" basedir="." default="">
    <condition property="test.exist">
        <and>
            <available file="test-1.0.jar" filepath="test/target/>
        </and>
    </condition>
    <target name="copy-target" if="test.exist" description="Test Copy">
        <copy todir="test/libdb" preservelastmodified="true">
            <fileset dir="test/target">
                <include name="test-1.0.jar"/>
            </fileset>
        </copy>
    </target>
    <target name="copy" unless="test.exist" depends="copy-target">
        <copy todir="test/libdb" preservelastmodified="true">
            <fileset dir="test/built">
                <include name="test-1.0.jar"/>
            </fileset>
        </copy>
    </target>
</project>
如果test/target中test-1.0.jar存在,就把它copy到test/libdb目錄下。
如果不存在就從test/built中把test-1.0.jar copy到test/libdb目錄下。

第二種:
1.先到http://ant-contrib.sourceforge.net/網(wǎng)站下載最新的ant-contrib.jar;
  1.1 copy ant-contrib.jar到ant安裝目錄下的lib目錄下,如果你想在你的工程中用這個if-else的tasks,就添加下面一行到你的 build.xml文件中:
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>

  1.2 也可以把ant-contrib.jar copy到一個相對獨立的目錄下,但是你在用的時候一定要指定這個目錄,以便于ant能找到它,例如(lib 目錄D:/ant-contrib),code如下:

<project name="test" basedir="." default="">
    <taskdef resource="net/sf/antcontrib/antcontrib.properties">
        <classpath>
            <pathelement location="D:/ant-contrib/ant-contrib-1.0b2.jar"/>
        </classpath>
    </taskdef>
    <available property="test.exist" file="test-1.0.jar" filepath="test/target"/>
    <target name="copy" description="Test Copy">
        <if>
            <isset property="test.exist"/>
            <then>
                <copy todir="test/libdb" preservelastmodified="true">
                    <fileset dir="test/target">
                        <include name="test-1.0.jar"/>
                    </fileset>
                </copy>
            </then>
            <else>
                <copy todir="test/libdb" preservelastmodified="true">
                    <fileset dir="test/built">
                        <include name="test-1.0.jar"/>
                    </fileset>
                </copy>
            </else>
        </if>
    </target>
</project>

2. available 釋意:
Available判斷某個類,或某個文件,或某個路徑。如果存在,則設(shè)置某個property。返回true.
其格式如下:
    判斷某個類是否存在:
    <available property="class.exist" classname="package.test" classpath ="dist/test.jar"/>
    判斷某個文件是否存在:
    <available property="file.exist" file="test.txt" filepath="src/test" type= "file"/>
    判斷某個資源是否存在:
    <available property="resource.exist" resource="package/test/test1.class" classpath="dist/test.jar"/>

3. ant-contrib參考地址:

http://ant-contrib.sourceforge.net/ant-contrib/manual/tasks/index.html

本站僅提供存儲服務,所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
ant-contrib 擴展ant 功能 for、foreach、if
怎樣用Ant測試Spring項目(Ant測試自動化--下
Hadoop2.4.0 Eclipse插件制作
hadoop eclipse plugin 編譯安裝,問題總結(jié)
Eclipse中使用ANT
Sun技術(shù)社區(qū) - Java,Solaris,SunONE,JES,StarSuite技術(shù)論壇 - Ant應用2
更多類似文章 >>
生活服務
分享 收藏 導長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服