Ant build.xml中應該只包含一個target標籤

今天在配置工程環境時,遇到一個Ant問題,之前一直都是由同事來管理這類環境問題的,但是他離職了,只能自己來研究。

下面是舊版本工程的build.xml內容:

<?xml version="1.0" encoding="UTF-8"?>

<project name="ccrl151" default="default" basedir=".">
    <description>Builds, tests, and runs the project ccrl151.</description>
    <import file="nbproject/build-impl.xml"/>

    <target name="-post-compile">
        <signjar alias="codesign2015" keystore="${build.web.dir}//keystore.jks"
                 storepass="xxxxxxxx" lazy="true">
            <path>
                <fileset dir="${build.web.dir}//jsp/hiscroapplet/lib" includes="*.jar" />
                <fileset dir="${build.web.dir}//jsp/hiscroapplet" includes="*.jar" />
            </path>
        </signjar>
    </target>
    <target depends="-init-check" name="deploy-with-quicksearch">
        <ant antfile="../ccrl151qh/build.xml" inheritall="false" target="dist">
            <property name="deploy.on.save" value="false"/>
        </ant>
        <copy todir="${build.web.dir}">
            <fileset dir="../ccrl151qh/build/web" excludes="META-INF/**,WEB-INF/**"/>
        </copy>
    </target>
</project>

這裏有兩個target,每個target執行一個任務。前一個是對所有jar包進行簽名。後一個是對資源項目進行構建,然後將構建好的資源複製到本項目的構建結果中。

但是我在創建新版本的工程之後,第二個target功能失效了。經過查看打印信息和分析,發現第二個target沒有被執行,不知道是什麼配置有問題。一時也沒有搜索到什麼方案,自己嘗試着添加echo打印信息,並把第二個target再次拆分成兩個target,看是哪個配置沒有通過,發現後面的兩個target都沒有執行。再後來突發一想,我直接把3個target進行合併,就好了。最後也沒有弄清楚爲何以前多個target可以運行成功,而現在只允許運行一個target。難道是Ant版本或者其他版本的問題?

只有一個target的build.xml:

<?xml version="1.0" encoding="UTF-8"?>

<project name="ccrl160" default="default" basedir=".">
    <description>Builds, tests, and runs the project ccrl160.</description>
    <import file="nbproject/build-impl.xml"/>

    <target name="-post-compile">
        <echo message="start signjar..."/>
        <signjar alias="codesign2015" keystore="${build.web.dir}//keystore.jks"
                 storepass="changeit" lazy="true">
            <path>
                <fileset dir="${build.web.dir}//jsp/hiscroapplet/lib" includes="*.jar" />
                <fileset dir="${build.web.dir}//jsp/hiscroapplet" includes="*.jar" />
            </path>
        </signjar>

        <echo message="start buile quicksearch..."/>
        <ant antfile="../ccrl160qh/build.xml" inheritall="false" target="dist">
            <property name="deploy.on.save" value="false"/>
        </ant>
        
        <echo message="start copy quicksearch..."/>
        <copy todir="${build.web.dir}">
            <fileset dir="../ccrl160qh/build/web" excludes="META-INF/**,WEB-INF/**"/>
        </copy>
    </target>

</project>


http://www.alanzeng.cn/2016/03/ant-build-xml-target/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章