Permalink
Fetching contributors…
Cannot retrieve contributors at this time
183 lines (175 sloc) 7.81 KB
<?xml version="1.0"?>
<project name="AssetLoader" basedir="." default="test">
<!-- set up a prefix for all environment variables -->
<property environment="env." />
<!-- load user properties to override defaults -->
<property file="user.properties" />
<!-- System environment must contain FLEX_HOME variable that points to Flex SDK -->
<property name="FLEX_HOME" location="${env.FLEX_HOME}" />
<!-- identify properties file -->
<property file="build.properties" />
<!-- Set up FlexUnit Ant tasks -->
<taskdef resource="flexUnitTasks.tasks" classpath="${lib.loc}/flexunit/flexUnitTasks.jar" />
<target name="usage">
<echo message="" />
<echo message="AssetLoader Build Usage" />
<echo message="-----------------------------------" />
<echo message="" />
<echo message="Available targets are:" />
<echo message="" />
<echo message="test --&gt; Build AssetLoader SWC and run unit tests" />
<echo message="asdoc --&gt; Build AssetLoader SWC, test, and generate asdocs" />
<echo message="package --&gt; Build AssetLoader SWC, test, and create release zip" />
<echo message="compile --&gt; Build AssetLoader SWC" />
<echo message="clean --&gt; Remove all folders created by build script" />
<echo message="init --&gt; Clean and create build folders" />
<echo message="" />
</target>
<!-- Clean Build and Report files -->
<target name="clean">
<!-- Remove all directories created during the build process -->
<echo>[clean] Removing Build and Report directories</echo>
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${report.loc}" defaultexcludes="false">
<include name="**/*" />
</fileset>
<fileset dir="${dist.loc}" defaultexcludes="false">
<include name="**/*" />
</fileset>
</delete>
<echo>[clean] Build and Report directories removed</echo>
</target>
<!-- Create directories needed for the build process -->
<target name="init" depends="clean">
<echo>[init] Creating Bin and Report directories</echo>
<mkdir dir="${bin.loc}" />
<mkdir dir="${report.loc}" />
<echo>[init] Bin and Report directories created</echo>
</target>
<!-- Compile Release SWC -->
<target name="compile" depends="init">
<echo>[compile] Compiling release SWC</echo>
<echo>[compile] Using Flex SDK at: ${FLEX_HOME}</echo>
<java jar="${FLEX_HOME}/lib/compc.jar" dir="${FLEX_HOME}/frameworks" fork="true" failonerror="true">
<!-- Build our SWC with a versioned name. -->
<arg value="-output=${bin.loc}/${project.name.versioned}.swc" />
<!-- We want all the org package classes in the SWC being built. -->
<arg value="-include-sources=${main.src.loc}/org" />
<!-- Include classes from SWCs in this folder, but only the ones we use. -->
<arg value="-library-path+=${lib.loc}" />
<!-- Boolean mosh pit! -->
<arg value="-incremental=true" />
<arg value="-static-link-runtime-shared-libraries=true" />
<arg value="-verbose-stacktraces=true" />
<arg value="-headless-server=true" />
</java>
<echo>[compile] Release SWC ${project.name.versioned}.swc created successfully</echo>
</target>
<!-- Run Unit Tests -->
<target name="test" depends="compile">
<echo>[test] Running Unit Tests</echo>
<!-- Compile FlexUnitRunner.mxml as a SWF -->
<java jar="${FLEX_HOME}/lib/mxmlc.jar" dir="${FLEX_HOME}/frameworks" fork="true" failonerror="true">
<arg value="${test.src.loc}/FlexUnitRunner.mxml" />
<arg value="-source-path=${main.src.loc}" />
<!-- Flash those sweet legs. Blink and you'll miss 'em. -->
<arg value="-output=${bin.loc}/testing/FlexTestSuite.swf" />
<arg value="-default-size=1024,400" />
<arg value="-default-background-color=0xFFFFFF" />
<!-- Include classes from SWCs in this folder, but only the ones we use. -->
<arg value="-library-path+=${lib.loc}"/>
<arg value="-library-path+=${lib.loc}/flexunit"/>
<!-- So true. -->
<arg value="-incremental=true" />
<arg value="-verbose-stacktraces=true" />
<arg value="-headless-server=true" />
</java>
<!-- Execute FlexTestSuite.swf as FlexUnit tests and publish reports -->
<echo>[test] Running SWF ${build.loc}/testing/FlexTestSuite.swf</echo>
<flexunit swf="${bin.loc}/testing/FlexTestSuite.swf" toDir="${report.loc}" haltonfailure="true" verbose="true" localTrusted="true" />
<!-- Generate readable JUnit-style reports -->
<junitreport todir="${report.loc}">
<fileset dir="${report.loc}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${report.loc}/html" />
</junitreport>
<echo>[test] Finished running Unit Tests</echo>
</target>
<!-- Build Documentation -->
<target name="asdoc" depends="test">
<echo>[asdoc] Generating ASDOC documentation</echo>
<tstamp>
<format property="docgen.time" pattern="MM/dd/yyyy hh:mm aa" unit="hour" />
</tstamp>
<java jar="${FLEX_HOME}/lib/asdoc.jar" dir="${FLEX_HOME}/frameworks" fork="true" failonerror="true">
<arg line="-external-library-path ${lib.loc}" />
<arg line="-doc-sources ${main.src.loc}" />
<arg line="-source-path ${main.src.loc}" />
<arg line="-output ${doc.loc}" />
<arg value="-keep-xml=true" />
<arg value="-lenient=true" />
<arg line="-window-title 'AssetLoader ${assetloader.ver.num}'" />
<arg line="-main-title 'AssetLoader ${assetloader.ver.num}'" />
<arg line="-footer 'AssetLoader - http://github.com/Matan/AssetLoader - Documentation generated at: ${docgen.time}'" />
<arg line="-package org.assetloader.base 'Base classes'" />
<arg line="-package org.assetloader.core 'The core AssetLoader apparatus contracts'" />
<arg line="-package org.assetloader.loaders 'The ILoader implementations'" />
<arg line="-package org.assetloader.parsers 'The IConfigParser implementations'" />
<arg line="-package org.assetloader.signals 'The custom AS3Signals dispatched from all ILoaders'" />
</java>
<echo>[asdoc] ASDOC documentation generated successfully</echo>
</target>
<!-- Package the Build -->
<target name="package" depends="asdoc">
<tstamp>
<format property="touch.time" pattern="MM/dd/yyyy hh:mm aa" unit="hour" />
</tstamp>
<!-- Assemble -->
<echo>[package] Packaging Release</echo>
<mkdir dir="${dist.loc}" />
<mkdir dir="${dist.loc}/bin" />
<mkdir dir="${dist.loc}/bin/examples" />
<mkdir dir="${dist.loc}/src" />
<mkdir dir="${dist.loc}/src_examples" />
<mkdir dir="${dist.loc}/libs" />
<copy file="${bin.loc}/${project.name.versioned}.swc" todir="${dist.loc}/bin" />
<copy file="${lib.loc}/${as3.signals.name.versioned}.swc" todir="${dist.loc}/libs" />
<copy file="${lib.loc}/${as3.corelib.json.name}.swc" todir="${dist.loc}/libs" />
<copy todir="${dist.loc}/src/org">
<fileset dir="${main.src.loc}/org" />
</copy>
<copy todir="${dist.loc}/src_examples/org">
<fileset dir="${exam.src.loc}/org" />
</copy>
<copy todir="${dist.loc}/bin/examples">
<fileset dir="${bin.loc}/examples" />
</copy>
<copy todir="${dist.loc}/docs">
<fileset dir="${doc.loc}" />
</copy>
<delete dir="${dist.loc}/docs/tempdita" />
<!-- Add ASDoc xml to swc for Flex Builder Tooltips -->
<zip destfile="${dist.loc}/bin/${project.name.versioned}.swc" update="true">
<zipfileset dir="${doc.loc}/tempdita" prefix="docs">
<include name="*packages.dita*" />
<include name="*org.*" />
</zipfileset>
</zip>
<!-- Copy LICENSE -->
<copy file="LICENSE" tofile="${dist.loc}/LICENSE" overwrite="true" />
<!-- Zip It -->
<zip destfile="${dist.loc}/${project.name.versioned}.zip">
<fileset dir="${dist.loc}" />
</zip>
<!-- Clean Up -->
<delete file="${dist.loc}/${project.name.versioned}.swc" />
<delete file="${dist.loc}/LICENSE" />
<delete dir="${dist.loc}/bin" />
<delete dir="${dist.loc}/src" />
<delete dir="${dist.loc}/src_examples" />
<delete dir="${dist.loc}/libs" />
<delete dir="${dist.loc}/docs" />
<echo>[package] Release packaged successfully</echo>
</target>
</project>