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

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

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

    cuiyi's blog(崔毅 crazycy)

    記錄點(diǎn)滴 鑒往事之得失 以資于發(fā)展
    數(shù)據(jù)加載中……

    ant腳本的javac怎么檢測源碼文件夾是否存在 ant javac check folder exists or not

    遇到了問題,編譯的時候,有一些目錄,比如
    tr\src
    tr\src_x1 for prj X1
    tr\src_x2 for prj X2
    _______  for prj X3, X3中沒有,怎么設(shè)置ant腳本呢?

    <target name="compile-tr">
            <mkdir dir="${tr.classes.dir}" />
            <javac destdir="${tr.classes.dir}" debug="${compiler.debug}" optimize="${compiler.optimize}" source="${compiler.source}" target="${compiler.target}" deprecation="true">
                <classpath>
                    <path refid="devel.lib" />
                </classpath>
                <src path="${tr.src.dir}" />
                <src path="${tr.src.dir}_${project.code}" />
            </javac>
    </target>

    在編譯X3的時候,這肯定是失敗的。

    怎么辦呢? 通過Condition和Avaliable來實(shí)現(xiàn)。(貼一個粗糙的示范實(shí)現(xiàn))


    <target name="compile-3tr" depends="dir.check" if="dir.exists">
            <mkdir dir="${tr.classes.dir}" />
            <javac destdir="${tr.classes.dir}" debug="${compiler.debug}" optimize="${compiler.optimize}" source="${compiler.source}" target="${compiler.target}" deprecation="true">
                <classpath>
                    <path refid="devel.lib" />
                </classpath>
                <src path="${tr.src.dir}" />
                <src path="${tr.src.dir}_${project.code}" />
            </javac>
    </target>
        
        <target name="dir.check">
            <condition property="dir.exists" value="true">
                <available file="${tr.src.dir}_${project.code}" type="dir"/>
            </condition>
            <mkdir dir="${tr.classes.dir}" />
        </target>

    居然在網(wǎng)上找到一個更贊的招

    <target name="go" depends="file-checks, do-something-with-first-file, do-something-with-second-file"/>

    <target name="file-checks">
       <available file="/home/doc/somefile"  property="first.file.found"/>
       <available file="/usr/local/somefile" property="second.file.found"/>
    </target>

    <target name="do-something-with-first-file" if="first.file.found">
       ???
    </target>

    <target name="do-something-with-second-file" if="second.file.found">
       ???
    </target>

    原來if....then....else需要ant-contrib的支持,怪不得我一直失敗
    ant-contrib

    <if>
        <available file="file1"/>
        <then>
          <property name="file.exists" value="true"/>
        </then>
        <else>
          <if>
            <available file="file2"/>
            <then>
              <copy file="file2" tofile="file1"/>
              <property name="file.exists" value="true"/>
            </then>
          </if>
        </else>
      </if>

    最后我很生氣的找到了apache本身的技術(shù)文檔 

    If/Unless Attributes

    http://ant.apache.org/manual/properties.html#if+unless

    If/Unless Attributes

    The <target> element and various tasks (such as <fail>) and task elements (such as <test> in <junit>) support if and unless attributes which can be used to control whether the item is run or otherwise takes effect.

    In Ant 1.7.1 and earlier, these attributes could only be property names. The item was enabled if a property with that name was defined - even to be the empty string or false - and disabled if the property was not defined. For example, the following works but there is no way to override the file existence check negatively (only positively):

    <target name="-check-use-file">
        <available property="file.exists" file="some-file"/>
    </target>
    <target name="use-file" depends="-check-use-file" if="file.exists">
        <!-- do something requiring that file -->
    </target>
    <target name="lots-of-stuff" depends="use-file,other-unconditional-stuff"/>
      
    As of Ant 1.8.0, you may instead use property expansion; a value of true (or on or yes) will enable the item, while false (or off or no) will disable it. Other values are still assumed to be property names and so the item is enabled only if the named property is defined.

    Compared to the older style, this gives you additional flexibility, because you can override the condition from the command line or parent scripts:

    <target name="-check-use-file" unless="file.exists">
        <available property="file.exists" file="some-file"/>
    </target>
    <target name="use-file" depends="-check-use-file" if="${file.exists}">
        <!-- do something requiring that file -->
    </target>
    <target name="lots-of-stuff" depends="use-file,other-unconditional-stuff"/>
      
    Now ant -Dfile.exists=false lots-of-stuff will run other-unconditional-stuff but not use-file, as you might expect, and you can disable the condition from another script too:

    <antcall target="lots-of-stuff">
        <param name="file.exists" value="false"/>
    </antcall>
      
    Similarly, an unless attribute disables the item if it is either the name of property which is defined, or if it evaluates to a true-like value. For example, the following allows you to define skip.printing.message=true in my-prefs.properties with the results you might expect:

    <property file="my-prefs.properties"/>
    <target name="print-message" unless="${skip.printing.message}">
        <echo>hello!</echo>
    </target>

    posted on 2013-04-16 14:52 crazycy 閱讀(3574) 評論(3)  編輯  收藏 所屬分類: JavaEE技術(shù)

    評論

    # re: ant腳本的javac怎么檢測源碼文件夾是否存在 ant javac check folder exists or not  回復(fù)  更多評論   

    public static void setpartV() throws WTException, WTPropertyVetoException {

    WTPart part = null;
    String vers = "B";
    String iteration = "2";
    wt.series.MultilevelSeries multilevelseries = null;
    part = (WTPart) wt.vc.VersionControlHelper.service.newVersion(part);
    // 設(shè)置大版本
    if (part.getMaster() != null) {
    String vseries = part.getMaster().getSeries();
    if (vseries == null) {
    if (part instanceof wt.inf.container.WTContained
    && (wt.inf.container.WTContained) part.getContainer() != null) {
    multilevelseries = wt.vc.VersionControlHelper
    .getVersionIdentifierSeries(part);
    wt.vc.VersionControlServerHelper.changeSeries(
    part.getMaster(),
    multilevelseries.getUniqueSeriesName());
    }
    } else {
    multilevelseries = MultilevelSeries.newMultilevelSeries(vers);
    }
    if (multilevelseries == null)
    multilevelseries = wt.series.MultilevelSeries
    .newMultilevelSeries("wt.vc.VersionIdentifier", vers);
    if (vers != null && !"".equals(vers))
    multilevelseries.setValueWithoutValidating(vers);
    wt.vc.VersionIdentifier versionidentifier = wt.vc.VersionIdentifier
    .newVersionIdentifier(multilevelseries);
    wt.vc.VersionControlServerHelper.setVersionIdentifier(part,
    versionidentifier, false);
    }
    // 設(shè)置小版本
    wt.series.Series series = wt.series.Series.newSeries(
    "wt.vc.IterationIdentifier", iteration);
    wt.vc.IterationIdentifier iterationid = wt.vc.IterationIdentifier
    .newIterationIdentifier(series);
    wt.vc.VersionControlHelper.setIterationIdentifier((Iterated) part,
    iterationid);
    part.setFederatableInfo(new FederatableInfo());

    }
    2013-04-16 16:24 | 11

    # re: ant腳本的javac怎么檢測源碼文件夾是否存在 ant javac check folder exists or not  回復(fù)  更多評論   

    感謝博主分享,學(xué)到了很多,利博亞洲www.libofun.com
    2013-04-16 16:45 | sdfsda

    # re: ant腳本的javac怎么檢測源碼文件夾是否存在 ant javac check folder exists or not  回復(fù)  更多評論   

    他 們 在那?
    2013-05-04 09:21 | 張治仕
    主站蜘蛛池模板: 永久免费无码网站在线观看个 | 曰批全过程免费视频在线观看 | 69天堂人成无码麻豆免费视频| 亚洲国产成人精品无码区在线观看| 韩国二级毛片免费播放| 亚洲神级电影国语版| 59pao成国产成视频永久免费| 久久亚洲春色中文字幕久久久| 三年片在线观看免费大全电影 | 国产精品亚洲精品日韩已满| a级毛片无码免费真人久久| 国产亚洲A∨片在线观看| 特级精品毛片免费观看| 亚洲国产成人久久99精品| 青娱乐免费在线视频| 亚洲国产成人精品无码区二本 | 亚洲中文字幕在线观看| 国产线视频精品免费观看视频| 亚洲人成网77777色在线播放| 久久久久国色av免费看| 亚洲天堂2016| 免费人成年激情视频在线观看 | 在线a免费观看最新网站| 亚洲一区二区观看播放| 免费又黄又硬又爽大片| 精品成人免费自拍视频| 亚洲国产精品美女| 国产伦一区二区三区免费| 中文成人久久久久影院免费观看| 亚洲激情中文字幕| 成人永久福利免费观看| 好湿好大好紧好爽免费视频| 综合自拍亚洲综合图不卡区| 麻豆国产入口在线观看免费| 国内永久免费crm系统z在线| 亚洲伊人久久大香线蕉在观| 亚洲偷自拍拍综合网| 99久久久国产精品免费无卡顿| 免费无码专区毛片高潮喷水| 亚洲视频一区在线观看| 免费va人成视频网站全|