Permalink
Switch branches/tags
Find file
Fetching contributors…
Cannot retrieve contributors at this time
181 lines (164 sloc) 7.25 KB
<project name="as3-signals" basedir="." default="swc">
<!-- Set up a prefix for all environment variables. -->
<property environment="env."/>
<fail unless="env.FLEX_HOME" message="FLEX_HOME needs to be defined as an environment variable or in the Ant build." />
<!-- Copy Flex SDK location from environment variable. This can be set manually instead. -->
<property name="FLEX_HOME" value="${env.FLEX_HOME}" />
<property file="build.properties"/>
<taskdef resource="flexUnitTasks.tasks" classpath="${libs.dir}/flexUnitTasks.jar" />
<target name="clean" description="Remove folders generated by the build.">
<echo>[clean] Removing generated folders.</echo>
<delete dir="${output.dir}" quiet="true" includeEmptyDirs="true"/>
<delete dir="${report.dir}" quiet="true" includeEmptyDirs="true"/>
<delete dir="${docs.dir}" quiet="true" includeEmptyDirs="true"/>
<delete dir="${dist.dir}" quiet="true" includeEmptyDirs="true"/>
</target>
<target name="swc" depends="clean" description="Compile AS3 code into a SWC.">
<echo>[swc] Building SWC</echo>
<echo>[swc] Using Flex SDK at: ${FLEX_HOME}</echo>
<mkdir dir="${output.dir}"/>
<java jar="${FLEX_HOME}/lib/compc.jar" dir="." fork="true" failonerror="true">
<arg value="+flexlib=${FLEX_HOME}/frameworks" />
<arg value="-incremental=true" />
<arg value="-source-path+=${src.dir}" />
<!-- Include all classes in this path. -->
<arg value="-include-sources=${src.dir}/${package.dir}" />
<!-- Link in classes from swc library (only those used). -->
<!--<arg value="-library-path+=${libs.dir}" />-->
<arg value="-output=${output.swc}" />
</java>
</target>
<target name="test" depends="swc" description="Run unit tests in a Flash Player window.">
<echo>[test] Running unit tests</echo>
<!-- Compile SWF -->
<java jar="${FLEX_HOME}/lib/mxmlc.jar" dir="${FLEX_HOME}/frameworks" fork="true" failonerror="true">
<arg value="${tests.dir}/${package.dir}/AllTestsRunner.as"/>
<arg value="-incremental=true"/>
<arg value="-source-path+=${src.dir}"/>
<arg value="-source-path+=${tests.dir}"/>
<arg value="-output=${tests.swf}"/>
<arg value="-target-player=10"/>
<arg value="-default-size=1000,800"/>
<arg value="-default-background-color=0x000000"/>
<arg value="-static-link-runtime-shared-libraries=true"/>
<!-- Include classes from SWCs in this folder, but only the ones we use. -->
<arg value="-library-path+=${libs.dir}"/>
<arg value="-verbose-stacktraces=true"/>
<arg value="-headless-server=true"/>
<arg value="-keep-as3-metadata+=Test,Suite,Before,BeforeClass,After,AfterClass,RunWith,Ignore,Inject"/>
</java>
<exec executable="open" os="Mac OS X">
<arg line='-a "flash player debugger" ${tests.swf}' />
</exec>
<exec executable="cmd.exe" osfamily="windows">
<arg line='/C start ${tests.swf}' />
</exec>
<exec executable="flashplayer" os="Linux">
<arg line="${tests.swf}"/>
</exec>
</target>
<target name="ci" depends="swc" description="Run unit tests and create JUnit-style reports for continuous integration.">
<echo>[ci] Running unit tests and generating reports</echo>
<mkdir dir="${report.dir}"/>
<!-- Compile SWF -->
<java jar="${FLEX_HOME}/lib/mxmlc.jar" dir="${FLEX_HOME}/frameworks" fork="true" failonerror="true">
<arg value="${tests.dir}/${package.dir}/AllTestsCIRunner.as"/>
<arg value="-incremental=true"/>
<arg value="-source-path+=${src.dir}"/>
<arg value="-source-path+=${tests.dir}"/>
<arg value="-output=${tests.swf}"/>
<arg value="-target-player=10"/>
<arg value="-default-size=1000,800"/>
<arg value="-default-background-color=0x000000"/>
<arg value="-static-link-runtime-shared-libraries=true"/>
<!-- Include classes from SWCs in this folder, but only the ones we use. -->
<arg value="-library-path+=${libs.dir}"/>
<arg value="-verbose-stacktraces=true"/>
<arg value="-headless-server=true"/>
<arg value="-keep-as3-metadata+=Test,Suite,Before,BeforeClass,After,AfterClass,RunWith,Ignore,Inject"/>
</java>
<!-- Execute test runner SWF and publish reports -->
<flexunit swf="${tests.swf}" toDir="${report.dir}" haltonfailure="false" verbose="true" localTrusted="false" />
<!-- Generate readable JUnit-style reports -->
<junitreport todir="${report.dir}">
<fileset dir="${report.dir}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${report.dir}/html" />
</junitreport>
</target>
<target name="asdoc" depends="swc" description="Create API docs for ${project.title}">
<echo>[asdoc] Generating ASDOC documentation</echo>
<mkdir dir="${docs.dir}"/>
<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+=${libs.dir}"/>-->
<arg line="-doc-sources+=${src.dir}/${package.dir}"/>
<arg line="-source-path+=${src.dir}"/>
<arg line="-output ${docs.dir}"/>
<arg value="-keep-xml=true"/>
<arg value="-lenient=true"/>
<arg line="-window-title '${project.title} ${ver.num}'"/>
<arg line="-main-title '${project.title} ${ver.num}'"/>
<arg line="-footer '${project.title} - Documentation generated at: ${docgen.time}'"/>
</java>
<echo>ASDOC documentation generated successfully.</echo>
</target>
<!-- Package the Build -->
<target name="package" depends="asdoc,ci">
<tstamp>
<format property="touch.time" pattern="MM/dd/yyyy hh:mm aa" unit="hour"/>
</tstamp>
<!-- Assemble -->
<echo>[package] Packaging Release</echo>
<mkdir dir="${dist.dir}"/>
<mkdir dir="${dist.dir}/bin"/>
<mkdir dir="${dist.dir}/src"/>
<mkdir dir="${dist.dir}/tests"/>
<mkdir dir="${dist.dir}/libs"/>
<copy file="${output.dir}/${project.name.versioned}.swc" todir="${dist.dir}/bin"/>
<copy todir="${dist.dir}/libs">
<fileset dir="${libs.dir}"/>
</copy>
<copy todir="${dist.dir}/src">
<fileset dir="${src.dir}"/>
</copy>
<copy todir="${dist.dir}/tests">
<fileset dir="${tests.dir}"/>
</copy>
<copy todir="${dist.dir}/docs">
<fileset dir="${docs.dir}"/>
</copy>
<delete dir="${dist.dir}/docs/tempdita"/>
<!-- Add ASDoc xml to swc for Flex Builder Tooltips -->
<zip destfile="${dist.dir}/bin/${project.name.versioned}.swc" update="true">
<zipfileset dir="${docs.dir}/tempdita" prefix="docs">
<include name="*packages.dita*"/>
<include name="*org.*"/>
</zipfileset>
</zip>
<!-- Copy README -->
<copy file="README.textile" tofile="${dist.dir}/README" overwrite="true"/>
<!-- Copy LICENSE -->
<copy file="MIT-LICENSE.txt" tofile="${dist.dir}/LICENSE" overwrite="true"/>
<!-- Copy CHANGELOG -->
<copy file="CHANGELOG.textile" tofile="${dist.dir}/CHANGELOG" overwrite="true"/>
<!-- Zip It -->
<zip destfile="${dist.dir}/${project.name.versioned}.zip">
<fileset dir="${dist.dir}"/>
</zip>
<!-- Clean Up -->
<delete file="${dist.dir}/${project.name.versioned}.swc"/>
<delete file="${dist.dir}/README"/>
<delete file="${dist.dir}/LICENSE"/>
<delete file="${dist.dir}/CHANGELOG"/>
<delete dir="${dist.dir}/bin"/>
<delete dir="${dist.dir}/src"/>
<delete dir="${dist.dir}/tests"/>
<delete dir="${dist.dir}/libs"/>
<delete dir="${dist.dir}/docs"/>
<echo>[package] Release packaged successfully</echo>
</target>
</project>