ciform/tools/ant-js.xml
cbonar abe7ad5541 # some refactoring (removed some levels of directories)
+ sha1 build scripts
+ top level README
2012-01-27 16:20:03 +01:00

219 lines
9.1 KiB
XML

<!--
Ant build template for Javascript projects.
To use it, projects must import this file into their own build.xml and define all variables.
-->
<project name="javascript" default="package" xmlns:ivy="antlib:org.apache.ivy.ant">
<!--
Loads dependent tasks
-->
<path id="ivy.lib.path">
<fileset file="${ant.ivytask.path}" />
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
<!--
Main targets : they are greatly inspired from the Maven build lifecycle
-->
<target name="validate" description="Validates the project is correct and all necessary information is available.">
<!-- Retrieves dependencies with ivy : required to initialize the cache and to get informations about the module being built -->
<ivy:retrieve />
<!-- Creates required directories -->
<mkdir dir="${target.dir}" />
</target>
<target name="compile" depends="validate" description="Compiles the source code of the project.">
<!-- We use this target to copy all required files for the tests together in a consistent hierarchy -->
<!--
<copy file="${jsunit.coreJs}" todir="${jsunit.tmp}"/>
<copy todir="${jsunit.tmp}" overwrite="true">
<resources refid="jsunit.in.files"/>
</copy>
-->
<!-- nothing more to do -->
</target>
<target name="test" depends="compile" description="Tests the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed.">
<!-- nothing more to do -->
</target>
<target name="package" depends="build-src, build-min, test, doc" description="Takes the compiled code and package it in its distributable format, such as a JAR.">
<!-- nothing more to do -->
</target>
<target name="integration-test" depends="package" description="Processes and deploys the package if necessary into an environment where integration tests can be run.">
<!-- Testing the compressed version of the library -->
<!-- Replaces the tested library with the compressed version -->
<!-- FIXME : it's not clean : it should not override a file already in build.dir -->
<!--
<copy file="${target.dir}/${ant.project.name}-compressed-${ivy.revision}.js" tofile="${build.dir}/sha1.js"/>
-->
<!--
<resources id="jsunit.in.files">
<file file="${build.dir}/sha1.js"/>
<fileset dir="${tests.dir}"/>
</resources>
-->
<!--
<antcall target="jsunit">
<reference refid="jsunit.in.files"/>
<param name="jsunit.in.testsuite" value="AllTests.html"/>
<param name="jsunit.out.logs" value="${tests.logs}"/>
</antcall>
-->
<!-- nothing more to do -->
</target>
<target name="verify" depends="integration-test" description="Runs any checks to verify the package is valid and meets quality criteria.">
<!-- nothing more to do -->
</target>
<target name="install" depends="build-src, build-min, test" description="Installs the package into the local repository, for use as a dependency in other projects locally.">
<!-- 'local' resolver is a default one bundled with Ivy -->
<!-- 'artifactspattern' must match the name of the files this script builds -->
<ivy:publish resolver="local" srcivypattern="ivy.xml" artifactspattern="${lib.dir}/[artifact]-[revision].[ext]" overwrite="true" forcedeliver="true" />
</target>
<target name="deploy" depends="verify" description="Done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.">
<!-- nothing more to do -->
</target>
<target name="clean" description="Restores the initial state of the project, deleting any generated file.">
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${build.dir}"/>
<fileset dir="${target.dir}"/>
</delete>
</target>
<!--
Some more specific targets
-->
<target name="doc" depends="validate" description="Generates developer documentation.">
<!-- Generates a report of dependencies -->
<ivy:report todir="${doc.dir}/ivy"/>
<!-- Generates the API doc -->
<!--<mkdir dir="${doc.dir}/api" />-->
<java jar="${jsdoc.dir}/jsrun.jar" fork="true" failonerror="true">
<arg file="${jsdoc.dir}/app/run.js" />
<arg file="${src.dir}"/>
<arg prefix="--template=" file="${jsdoc.dir}/templates/jsdoc" />
<arg value="--allfunctions" />
<arg value="--private" />
<arg prefix="--directory=" file="${doc.dir}/api"/>
<arg value="--recurse"/>
<arg value="--verbose" />
</java>
<echo message="Done generating doc." />
</target>
<!--
Takes all *.js files inside ${src.dir} as input.
Creates a file name after the new property 'build.bigsource.js'.
-->
<target name="concat-sources" depends="validate" description="Copies all source scripts into one big file for further work on it." >
<tempfile property="build.bigsource.js" destDir="${build.dir}" prefix="${ant.project.name}" suffix=".js" />
<!-- TODO handle encoding (and eol?) -->
<concat destfile="${build.bigsource.js}">
<fileset dir="${src.dir}">
<include name="**/*.js" />
</fileset>
</concat>
<echo message="Created : ${build.bigsource.js}" level="verbose" />
</target>
<target name="build-src" depends="concat-sources" description="Builds the default .js.">
<copy file="${build.bigsource.js}" tofile="${lib.dir}/${ivy.module}-${ivy.revision}.js" />
<echo message="Copied : ${lib.dir}/${ivy.module}-${ivy.revision}.js" />
</target>
<target name="build-min" depends="concat-sources" description="Builds a minified version of the .js.">
<java jar="${yuicompressor.jar}" fork="true" output="${lib.dir}/${ivy.module}-min-${ivy.revision}.js" failonerror="true">
<arg line="--type js" />
<arg file="${build.bigsource.js}"/>
</java>
<echo message="Minified : ${lib.dir}/${ivy.module}-min-${ivy.revision}.js" />
</target>
<!--
TODO fix and integrate the following targets
-->
<!--
Runs JsUnit tests. This target saves a lot of verbosity in the projects' build scripts.
Firefox 3 users : change the security.fileuri.strict_origin_policy parameter to 'false' for the following target to work
// static configuration
@in jsunit.dir the directory where JsUnit resides
@in jsunit.coreJs the jsUnitCore.js file
@in jsunit.testRunner the test runner's HTML page
-->
<!--<taskdef name="jsunit" classname="net.jsunit.ant.StandaloneTestTask" classpath="/home/cbonar/src/jsunit/java/bin" />-->
<!-- NOTE : These tests should not require the code be packaged or deployed. -->
<target name="test-fixme" depends="compile" description="Tests the compiled source code using a suitable unit testing framework.">
<jsunit showoutput="true"
printsummary="true"
filtertrace="false"
jsUnitRoot="${jsunit.dir}"
haltonfailure="true"
haltonerror="true"
>
<sysproperty key="browserFileNames" value="${jsunit.browsers}"/>
<sysproperty key="port" value="45678"/>
<sysproperty key="logsDirectory" value="${tests.logs}"/>
<test todir="${tests.logs}">
<fileset dir="${src.dir}" includes="**/*.js"/>
<fileset dir="${tests.dir}" includes="**/*.js"/>
</test>
<!--
<scripts dir="${src.dir}" includes="**/*.js"/>
<scripts dir="${tests.dir}" includes="**/*.js"/>
-->
<classpath>
<fileset dir="${jsunit.dir}/java/lib">
<include name="*.jar"/>
</fileset>
<!--
<fileset dir="${jsunit.dir}/java/bin">
<include name="jsunit.jar"/>
</fileset>
-->
<dirset dir="/home/cbonar/src/jsunit/java/bin"/>
<dirset dir="${jsunit.dir}/java/config"/>
</classpath>
<formatter type="xml"/>
</jsunit>
</target>
<!-- Generates developer documentation using (old) jsdoc. -->
<target name="jsdoc" depends="validate">
<!-- Generates a report of dependencies -->
<ivy:report todir="${doc.dir}"/>
<!-- Generates the API doc -->
<exec command="${jsdoc}" failonerror="true">
<arg value="-d"/> <arg value="${doc.dir}"/>
<arg value="--no-lexical-privates"/>
<arg value="--package-naming"/>
<arg value="--nested-file-naming"/>
<arg line="--project-name Crypto.SHA1"/>
<arg value="${src.dir}"/>
</exec>
</target>
</project>