Ant脚本:如何用不同的属性值使用相同的目标



我想调用一个目标,两次:第一次除非外部库名为"temp.swc",第二次使用这个外部库。

<target name="build-trinity-client">
    <mxmlc 
        file="${src.dir}/${trinity.project}.mxml"
        output="${release.dir}/${trinity-client}.swf"
        locale="fr_FR"
        static-rsls="true"
        accessible="true"
        configname="air"
        debug="false"
        failonerror="true"
        fork="true"
        maxmemory="512m">
            <source-path path-element="${src.dir}"/>
            <external-library-path file="${FLEX_HOME}/frameworks/libs/air/airglobal.swc" append="true"/>
            <library-path dir="${ivy.cache.dir}" append="true">
                <include name="${puremvc.lib}"/>
                <include name="${kccalendar.lib}"/>
                <include name="${as3commons.lib}"/>
                <include name="d:/temp.swc"/>
            </library-path>             
    </mxmlc>
</target>

你应该使用antcall标签和if标签:

<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<target name="build-trinity-client">
    <if>
        <isset property="swc.name"/>
        <then>
            <mxmlc 
                file="${src.dir}/${trinity.project}.mxml"
                output="${release.dir}/${trinity-client}.swf"
                locale="fr_FR"
                static-rsls="true"
                accessible="true"
                configname="air"
                debug="false"
                failonerror="true"
                fork="true"
                maxmemory="512m">
                <source-path path-element="${src.dir}"/>
                <external-library-path file="${FLEX_HOME}/frameworks/libs/air/airglobal.swc" append="true"/>
                <library-path dir="${ivy.cache.dir}" append="true">
                    <include name="${puremvc.lib}"/>
                    <include name="${kccalendar.lib}"/>
                    <include name="${as3commons.lib}"/>
                    <include name="${swc.name}"/>
                </library-path>             
            </mxmlc>
        </then>
        <else>
            <mxmlc 
                file="${src.dir}/${trinity.project}.mxml"
                output="${release.dir}/${trinity-client}.swf"
                locale="fr_FR"
                static-rsls="true"
                accessible="true"
                configname="air"
                debug="false"
                failonerror="true"
                fork="true"
                maxmemory="512m">
                <source-path path-element="${src.dir}"/>
                <external-library-path file="${FLEX_HOME}/frameworks/libs/air/airglobal.swc" append="true"/>
                <library-path dir="${ivy.cache.dir}" append="true">
                    <include name="${puremvc.lib}"/>
                    <include name="${kccalendar.lib}"/>
                    <include name="${as3commons.lib}"/>
                </library-path>             
            </mxmlc>
        </else>
    </if>
</target>
<target name="sample_call">
    <echo>First call: library name is passing</echo>
    <antcall target="build-trinity-client">
        <param name="swc.name" value="d:/temp.swc"/>
    </antcall> 
    <echo>Second call: don't use external library</echo>
    <antcall target="build-trinity-client">
        <param name="swc.name" value=""/>
    </antcall> 
</target>

相关内容

  • 没有找到相关文章

最新更新