Ant build 文件示例

本文介绍了一个使用 Flex SDK 和 Ant 构建脚本来编译 MXML 和 AS3 文件的示例。该构建脚本定义了多个目标,包括初始化环境、清理目录、构建源代码和单元测试、运行单元测试、打包应用程序等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<project name="Flex Ant Tasks Build Script" default="build" basedir=".">

   <property name="home.dir" location="${basedir}"/>
    <property name="FLEX_HOME" value="C:/CIEnv/tools/flex_sdk_4.0.0.14159"/>
    <property name="AIR_HOME" value="${FLEX_HOME}"/>
    <property name="src.dir" location="${home.dir}/src"/>
    <property name="test.dir" location="${home.dir}/src/unittest"/>
    <property name="bin.dir" location="${home.dir}/bin-debug"/>
    <property name="lib.dir" location="${home.dir}/libs"/>
   
    <property name="ADL" value="${AIR_HOME}/bin/adl.exe"/>
    <property name="ADT.JAR" value="${AIR_HOME}/lib/adt.jar"/>
   
    <property name="appName" value="AntTest"/>
    <property name="appTestRunner" value="AntTestRunner"/>
   
    <!-- executable files including XML and SWF files -->
    <property name="target.build.dir" location="${home.dir}/target_build"/>
    <property name="target.unittest.dir" location="${home.dir}/target_unittest"/>
    <!-- zip files for deploying to other running machines -->
    <property name="deploy.dir" location="${home.dir}/deploy"/>
    <property name="report.dir" location="${home.dir}/report"/>
       
    <taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
    <taskdef resource="flexUnitTasks.tasks" classpath="${home.dir}/libs/flexUnitTasks-4.0.0.jar" />
       
    <target name="init">
        <echo message="Init build script at ${home.dir}"/>
        <echo message="Flex SDK home at ${FLEX_HOME}"/>
        <echo message="Build output to target folder ${target.dir}"/>
    </target>
   
    <target name="cleanBuildTarget">
        <delete dir="${target.build.dir}" />
        <mkdir dir="${target.build.dir}" />
    </target>

    <target name="cleanUnitTestTarget">
        <delete dir="${target.unittest.dir}" />
        <mkdir dir="${target.unittest.dir}" />
    </target>
   
    <target name="cleanDeploy">
        <delete dir="${deploy.dir}" />
        <mkdir dir="${deploy.dir}" />
    </target>   
   
    <target name="cleanReport">
        <delete dir="${report.dir}" />
        <mkdir dir="${report.dir}" />
    </target>   
           
    <target name="buildSrc" depends="init, cleanBuildTarget">
        <mxmlc
            file="${src.dir}/${appName}.mxml"
            output="${target.build.dir}/${appName}.swf"
            actionscript-file-encoding="UTF-8"
            incremental="true"
            locale="en_US"
        >
            <source-path path-element="${src.dir}"/>
            <compiler.library-path dir="${lib.dir}" append="true">
                <include name="*.swc" />
            </compiler.library-path>
            <load-config filename="${FLEX_HOME}/frameworks/air-config.xml"/>
        </mxmlc>
    </target>
   
    <target name="buildUnitTest" depends="init, cleanUnitTestTarget">
        <mxmlc
            file="${src.dir}/${appTestRunner}.mxml"
            output="${target.unittest.dir}/${appTestRunner}.swf"
            actionscript-file-encoding="UTF-8"
            incremental="true"
            locale="en_US"
        >

            <source-path path-element="${src.dir}"/>
            <compiler.library-path dir="${lib.dir}" append="true">
                <include name="*.swc" />
            </compiler.library-path>
            <load-config filename="${FLEX_HOME}/frameworks/air-config.xml"/>
        </mxmlc>
    </target>
   
    <target name="build">
        <antcall target="buildSrc"/>
        <antcall target="buildUnitTest"/>
    </target>
       
    <target name="runUnitTest" depends="buildUnitTest, cleanDeploy, cleanReport">
        <sequential>
            <flexunit
                player="air"
                swf="${target.unittest.dir}/${appTestRunner}.swf"
                toDir="${deploy.dir}"
                haltonfailure="false"
                verbose="true"
                localTrusted="true"
            />
       
            <junitreport todir="${deploy.dir}">
                <fileset dir="${deploy.dir}">
                    <include name="TEST-*.xml"/>
                  </fileset>
                  <report format="noframes" todir="${report.dir}"/>
            </junitreport>
        </sequential>

    </target>       

    <target name="runADL" depends="buildSrc">
        <sequential>
            <copy file="${bin.dir}/${appName}-app.xml" tofile="${target.build.dir}/${appName}-app.xml" />
            <exec executable="${ADL}">
                <arg value="${target.build.dir}/${appName}-app.xml"/>
            </exec>
        </sequential>   
    </target>
   
    <target name="runADT" depends="buildSrc">
        <java jar="${ADT.JAR}" fork="true" fail dir="${target.build.dir}/">
            <arg value="-package"/>
            <arg value="-storetype"/>
            <arg value="pkcs12"/>
            <arg value="-keystore"/>
            <arg value="${home.dir}/AirKey/${appName}.p12"/>
            <arg value="-storepass"/>
            <arg value="test"/>
            <arg value="${appName}.air"/>
            <arg value="${bin.dir}/${appName}-app.xml"/>    
            <arg value="-C"/>
            <arg value="${bin.dir}"/>
            <arg value="${appName}.swf"/>
        </java>        
    </target>
   
    <target name="package" depends="buildSrc, buildUnitTest, cleanDeploy">
        <zip destfile="${deploy.dir}/${appName}.zip">
            <fileset dir="${target.build.dir}" excludes="*.cache"/>
            <fileset dir="${target.unittest.dir}" excludes="*.cache"/>
        </zip>
        <zip destfile="${deploy.dir}/${appName}_SRC_0_1.zip">
            <fileset dir="${home.dir}" includes="src*.xml"/>
                            </fileset>
                        </attachments>
                </mail>
        </target>

</project> 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值