<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>
<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>