Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
224 lines (200 sloc) 9.86 KB
<?xml version="1.0" encoding="UTF-8"?>
<project name="site_stream" default="all">
<!-- TODO: flex unit test coverage -->
<!-- Sets up all required build properties -->
<target name="-init">
<!-- External props -->
<property environment="env"/>
<property file="${basedir}/build.user.properties" />
<property name="build.properties.loc" location="${basedir}/build.properties" />
<property file="${build.properties.loc}" />
<!-- flex.sdk.loc should point to the root directory of the flex sdk, 4.5.0
to override the FLEX_HOME environment variable, use the build.user.properties file -->
<property name="flex.sdk.loc" value="${env.FLEX_HOME}" />
<!-- General Source -->
<property name="src.loc" location="${basedir}/siteStreamSrc" />
<property name="test.src.loc" location="${basedir}/testSrc" />
<property name="libs.loc" location="${basedir}/libs" />
<!-- Build Config -->
<property name="config.loc" location="${basedir}/config" />
<property name="config.flex" value="${config.loc}/flex-config.xml" />
<!-- General Build -->
<property name="build.loc" location="${basedir}/build" />
<property name="build.api.loc" location="${build.loc}/api" />
<property name="build.release.loc" location="${build.loc}/release" />
<property name="build.release.compile.loc"
location="${build.release.loc}/${build.name}-${build.version}_${build.num}.swc" />
<property name="build.release.package.loc"
location="${build.release.loc}/${build.name}-${build.version}_${build.num}.zip" />
<property name="build.analysis.loc" location="${build.loc}/analysis" />
<property name="build.test.loc" location="${build.loc}/test" />
<property name="build.test.reports.loc" location="${build.test.loc}/reports" />
<!-- Flex tasks -->
<property name="FLEX_HOME" value="${flex.sdk.loc}" />
<taskdef resource="flexTasks.tasks" classpath="${flex.sdk.loc}/ant/lib/flexTasks.jar" />
<!-- FlexUnit -->
<taskdef resource="flexUnitTasks.tasks"
classpath="${libs.loc}/flexUnitTasks-4.1.0_RC2-4.jar" />
<!-- FlexCPD -->
<property name="flexpmd.version" value="1.2" />
<taskdef name="flexcpd" classname="com.adobe.ac.cpd.ant.FlexCpdAntTask"
classpath="${libs.loc}/flex-pmd-cpd-ant-task-${flexpmd.version}.jar">
<classpath>
<pathelement location="${libs.loc}/flex-pmd-files-${flexpmd.version}.jar" />
<pathelement location="${libs.loc}/flex-pmd-cpd-${flexpmd.version}.jar" />
<pathelement location="${libs.loc}/as3-plugin-utils-${flexpmd.version}.jar" />
<pathelement location="${libs.loc}/as3-parser-${flexpmd.version}.jar" />
<pathelement location="${libs.loc}/as3-parser-api-${flexpmd.version}.jar" />
<pathelement location="${libs.loc}/pmd-4.2.5.jar" />
</classpath>
</taskdef>
<!-- FlexPMD -->
<taskdef name="flexpmd" classname="com.adobe.ac.pmd.ant.FlexPmdAntTask"
classpath="${libs.loc}/flex-pmd-ant-task-${flexpmd.version}.jar">
<classpath>
<pathelement location="${libs.loc}/flex-pmd-core-${flexpmd.version}.jar" />
<pathelement location="${libs.loc}/flex-pmd-files-${flexpmd.version}.jar" />
<pathelement location="${libs.loc}/flex-pmd-ruleset-${flexpmd.version}.jar" />
<pathelement location="${libs.loc}/as3-plugin-utils-${flexpmd.version}.jar" />
<pathelement location="${libs.loc}/as3-parser-${flexpmd.version}.jar" />
<pathelement location="${libs.loc}/as3-parser-api-${flexpmd.version}.jar" />
<pathelement location="${libs.loc}/commons-lang-2.4.jar" />
<pathelement location="${libs.loc}/flex-pmd-ruleset-api-${flexpmd.version}.jar" />
<pathelement location="${libs.loc}/pmd-4.2.5.jar" />
<pathelement location="${libs.loc}/plexus-utils-1.0.2.jar" />
</classpath>
</taskdef>
<!-- FlexMetrics -->
<taskdef name="flexmetrics" classname="com.adobe.ac.pmd.metrics.ant.FlexMetricsAntTask"
classpath="${libs.loc}/flex-pmd-metrics-ant-task-${flexpmd.version}.jar">
<classpath>
<pathelement location="${libs.loc}/flex-pmd-files-${flexpmd.version}.jar" />
<pathelement location="${libs.loc}/flex-pmd-metrics-${flexpmd.version}.jar" />
<pathelement location="${libs.loc}/as3-plugin-utils-${flexpmd.version}.jar" />
<pathelement location="${libs.loc}/as3-parser-${flexpmd.version}.jar" />
<pathelement location="${libs.loc}/as3-parser-api-${flexpmd.version}.jar" />
<pathelement location="${libs.loc}/commons-lang-2.4.jar" />
<pathelement location="${libs.loc}/flex-pmd-ruleset-api-${flexpmd.version}.jar" />
<pathelement location="${libs.loc}/pmd-4.2.5.jar" />
<pathelement location="${libs.loc}/dom4j-1.6.1.jar"/>
</classpath>
</taskdef>
</target>
<!-- Remove build artifacts -->
<target name="clean" depends="-init" description="Remove build artifacts">
<delete dir="${build.loc}" />
</target>
<!-- Setup build artifacts directories -->
<target name="-prepare" depends="clean">
<mkdir dir="${build.loc}" />
<mkdir dir="${build.release.loc}" />
<mkdir dir="${build.analysis.loc}" />
<mkdir dir="${build.test.loc}" />
<mkdir dir="${build.test.reports.loc}" />
</target>
<!-- Run all tests and create a debug build of the library -->
<!-- TODO: Add test to all once can get to work in CI environment -->
<target name="all" depends="analyse,doc,package"
description="Run all tests and create a package of the library" />
<!-- Generate all documentation -->
<target name="doc" depends="doc-api" description="Generate all documentation" />
<!-- Generate API Documentation -->
<target name="doc-api" depends="-prepare" description="Generates API Documentation">
<asdoc output="${build.api.loc}" lenient="false" failonerror="true">
<doc-sources path-element="${src.loc}" />
<external-library-path file="${libs.loc}/tbyrne.swc" />
</asdoc>
</target>
<!-- Creates an SWC of the library -->
<target name="compile" depends="-prepare"
description="Create an SWC of the library">
<compileswc file="${build.release.compile.loc}" />
<propertyfile file="${build.properties.loc}">
<entry key="build.num" default="0" value="1" type="int" operation="+" />
</propertyfile>
</target>
<!-- Creates a debug SWC of the library -->
<target name="compile-debug" depends="-prepare"
description="Create a debug SWC of the library">
<compileswc file="${build.release.compile.loc}" debug="true" />
<propertyfile file="${build.properties.loc}">
<entry key="build.num" default="0" value="1" type="int" operation="+" />
</propertyfile>
</target>
<!-- Creates a full distributable package -->
<target name="package" depends="doc,compile">
<!-- TODO: Examples, example projects, docs, etc. -->
<zip destfile="${build.release.package.loc}">
<zipfileset file="${build.release.compile.loc}"
fullpath="${build.name}-${build.version}.swc" />
<zipfileset file="${libs.loc}/tbyrne.swc" />
<zipfileset dir="${build.api.loc}" prefix="doc/api" />
</zip>
</target>
<!-- Build a release package for the current library -->
<target name="release" depends="test,package"
description="Build a release package for the current library">
<move file="${build.release.compile.loc}"
tofile="${build.release.loc}/${build.name}-${build.version}.swc" />
<move file="${build.release.package.loc}"
tofile="${build.release.loc}/${build.name}-${build.version}.zip" />
<!-- TODO: make a git tag -->
<!-- TODO: Upload to github downloads? -->
</target>
<!-- Run all tests -->
<target name="test" depends="-prepare" description="Run all tests">
<flexunit workingDir="${build.test.loc}" toDir="${build.test.reports.loc}"
haltonfailure="true" verbose="false" localTrusted="true">
<source dir="${src.loc}" />
<testSource dir="${test.src.loc}">
<!--<include name="**/*Test.as" />-->
<include name="ExampleTest.as" />
</testSource>
<library dir="${libs.loc}" />
</flexunit>
<junitreport todir="${build.test.reports.loc}">
<fileset dir="${build.test.reports.loc}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${build.test.reports.loc}/html" />
</junitreport>
</target>
<!-- Run all analysis -->
<target name="analyse" depends="analyse-cpd,analyse-metrics,analyse-pmd"
description="Run all analysis" />
<!-- Run CPD Analysis -->
<target name="analyse-cpd" depends="-prepare" description="Runs CPD Analysis">
<flexcpd minimumTokenCount="50" outputFile="${build.analysis.loc}/cpd.xml">
<fileset dir="${src.loc}">
<include name="**/*.as"/>
</fileset>
</flexcpd>
</target>
<!-- Run Metrics Analysis -->
<target name="analyse-metrics" depends="-prepare" description="Run Metrics Analysis">
<flexmetrics sourcedirectory="${src.loc}" outputfile="${build.analysis.loc}/metrics.xml"/>
</target>
<!-- Run PMD Analysis -->
<target name="analyse-pmd" depends="-prepare" description="Run PMD Analysis">
<flexpmd sourceDirectory="${src.loc}" outputDirectory="${build.analysis.loc}/pmd" />
<!--ruleset="${basedir}/pmd-ruleset.xml" />-->
</target>
<!-- Compile swc version of the library -->
<macrodef name="compileswc">
<attribute name="file" />
<attribute name="debug" default="false" />
<sequential>
<compc output="@{file}" debug="@{debug}">
<source-path path-element="${src.loc}" />
<include-sources dir="${src.loc}" includes="**/*.as" />
<external-library-path dir="${libs.loc}">
<include name="*.swc"/>
</external-library-path>
<load-config filename="${config.flex}" />
<external-library-path dir="${flex.sdk.loc}/frameworks/libs/player/10.0">
<include name="*.swc"/>
</external-library-path>
</compc>
</sequential>
</macrodef>
</project>