mirror of
https://github.com/nicolabs/ciform.git
synced 2025-09-07 16:10:07 +02:00
410 lines
19 KiB
XML
410 lines
19 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.
|
|
-->
|
|
<!-- TODO define all base targets as extension-point and make javascript.* targets -->
|
|
<project name="javascript" default="package" xmlns:ivy="antlib:org.apache.ivy.ant" xmlns:artifact="antlib:org.apache.maven.artifact.ant">
|
|
|
|
<!--
|
|
Loads default properties : simple convenience (not specific to Javascript)
|
|
-->
|
|
|
|
<!-- example of use : local properties for the main project only -->
|
|
<property file="local.properties"/>
|
|
<!-- example of use : default properties for the main project only -->
|
|
<property file="build.properties"/>
|
|
<!-- example of use : default generic properties -->
|
|
<property file="default.properties"/>
|
|
|
|
<!-- shorthand properties -->
|
|
<property name="target.lib.dir" value="${target.dir}/lib" />
|
|
|
|
<!--
|
|
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 phases : they are greatly inspired from the Maven build lifecycle
|
|
See http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference
|
|
-->
|
|
|
|
<extension-point name="validate" description="Validates the project is correct and all necessary information is available." />
|
|
|
|
<extension-point name="compile" depends="validate" description="Compiles the source code of the project." />
|
|
|
|
<extension-point 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." />
|
|
|
|
<extension-point name="package" depends="-check-package, test" unless="package.exists" description="Takes the compiled code and package it in its distributable format, such as a JAR." />
|
|
|
|
<extension-point name="integration-test" depends="package" description="Processes and deploys the package if necessary into an environment where integration tests can be run." />
|
|
|
|
<extension-point name="verify" depends="integration-test" description="Runs any checks to verify the package is valid and meets quality criteria." />
|
|
|
|
<extension-point name="install" depends="verify" description="Installs the package into the local repository, for use as a dependency in other projects locally." />
|
|
|
|
<extension-point 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." />
|
|
|
|
<extension-point name="site" depends="verify" description="Generates site documentation for this project. This also includes snapshot releases in Ivy repository style." />
|
|
|
|
<extension-point name="clean" description="Restores the initial state of the project, deleting any generated file." />
|
|
|
|
|
|
<!--
|
|
Targets that implement "phases" (extension points)
|
|
-->
|
|
|
|
<target name="init-build" extensionOf="validate" description="Builds initial directories and makes sure all dependencies are there.">
|
|
<!-- Retrieves dependencies with ivy : required to initialize the cache and to get informations about the module being built -->
|
|
<!-- We use the default pattern, but put the resolved artifacts in a directory of ours so we can delete it afterwards -->
|
|
<ivy:retrieve pattern="${build.dir}/ivy/[conf]/[artifact].[ext]" sync="true" />
|
|
<!-- Creates required directories -->
|
|
<mkdir dir="${target.dir}" />
|
|
<!-- TODO check tools dependencies -->
|
|
</target>
|
|
|
|
<target name="-check-package" description="Checks that artifacts have been generated ; if not triggers the target 'integration-test'." >
|
|
<available property="package.exists" file="${target.lib.dir}/${ivy.module}.js" />
|
|
</target>
|
|
|
|
<target name="ivy-install" extensionOf="install" depends="verify" description="Builds and installs the artifacts into the local Ivy repository.">
|
|
<!-- 'local' resolver is a default one bundled with Ivy ; it resides in the user's home directory -->
|
|
<!-- 'artifactspattern' must match the name of the files this script builds -->
|
|
<!-- Note : We use all options to force overwriting of existing (and possibly deprecated, during development) files -->
|
|
<ivy:publish resolver="local" artifactspattern="${target.lib.dir}/[artifact].[ext]" overwrite="true" forcedeliver="true" publishivy="true" />
|
|
</target>
|
|
|
|
<target name="make-clean" extensionOf="clean" description="Deletes build and target directories">
|
|
<!-- NOTE 'dir' attribute is more efficient at deleting dirs than nested <fileset dir='...' /> -->
|
|
<delete dir="${build.dir}" deleteonexit="true" failonerror="false" />
|
|
<delete dir="${target.dir}" deleteonexit="true" failonerror="false" />
|
|
</target>
|
|
|
|
<target name="doc" extensionOf="package" depends="validate" description="Generates API documentation for this project and other technical reports.">
|
|
|
|
<!-- Generates a report of dependencies -->
|
|
<ivy:report todir="${target.dir}/doc/ivy"/>
|
|
|
|
<!-- Generates the API doc -->
|
|
<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.template.dir}" />
|
|
<arg prefix="--define=" value="projectName:${ant.project.name}" />
|
|
<arg prefix="--define=" value="projectLicense:${project.license}" />
|
|
<arg value="--allfunctions" />
|
|
<arg value="--private" />
|
|
<arg prefix="--directory=" file="${target.dir}/doc/api/js"/>
|
|
<arg value="--recurse"/>
|
|
<arg value="--verbose" />
|
|
</java>
|
|
<!-- TODO check return code (it may fail) -->
|
|
|
|
<echo message="Done generating site." />
|
|
|
|
</target>
|
|
|
|
<!--
|
|
Takes all *.js files inside ${src.dir} as input.
|
|
Creates a file name after the new property 'build.bigsource.js'.
|
|
-->
|
|
<target name="build-bigsource" 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>
|
|
|
|
<macrodef name="minify" description="Builds a minified version of the .js.">
|
|
<attribute name="file" />
|
|
<attribute name="tofile" />
|
|
<sequential>
|
|
<java jar="${yuicompressor.jar}" fork="true" output="@{tofile}" failonerror="true">
|
|
<arg line="--type js" />
|
|
<arg file="@{file}"/>
|
|
</java>
|
|
<echo message="Minified : @{tofile}" level="verbose" />
|
|
</sequential>
|
|
</macrodef>
|
|
|
|
<macrodef name="build-default" description="Builds the default .js.">
|
|
<attribute name="bigsource" />
|
|
<attribute name="module" default="${ivy.module}" />
|
|
<sequential>
|
|
<local name="file" />
|
|
<property name="file" value="${target.lib.dir}/@{module}.js" />
|
|
<copy file="@{bigsource}" tofile="${file}" />
|
|
<echo message="Built : ${file}" />
|
|
</sequential>
|
|
</macrodef>
|
|
|
|
<macrodef name="build-minified" description="Builds a minified version of the .js.">
|
|
<attribute name="bigsource" />
|
|
<attribute name="module" default="${ivy.module}" />
|
|
<sequential>
|
|
<local name="file" />
|
|
<property name="file" value="${target.lib.dir}/@{module}-min.js" />
|
|
<minify file="@{bigsource}" tofile="${file}" />
|
|
<echo message="Built (minified) : ${file}" />
|
|
</sequential>
|
|
</macrodef>
|
|
|
|
<target name="build-default" extensionOf="package" depends="build-bigsource" description="Builds the default .js.">
|
|
<build-default bigsource="${build.bigsource.js}" />
|
|
</target>
|
|
|
|
<target name="build-minified" extensionOf="package" depends="build-bigsource" description="Builds a minified version of the .js.">
|
|
<build-minified bigsource="${build.bigsource.js}" />
|
|
</target>
|
|
|
|
<!-- TODO Works but misses minified artifact amongst other things ; see http://ant.1045680.n5.nabble.com/Review-Needed-for-quot-Publishing-Maven-Artifacts-with-Ivy-quot-Doc-td3204659.html -->
|
|
<target name="build-pom" extensionOf="package" depends="validate" description="Builds a Maven POM.">
|
|
<ivy:makepom ivyfile="${basedir}/ivy.xml" pomfile="${target.dir}/${ivy.module}.pom" templatefile="pom.xml">
|
|
<mapping conf="default" scope="test"/>
|
|
<mapping conf="minified" scope="compile"/>
|
|
</ivy:makepom>
|
|
</target>
|
|
|
|
<target name="hg-site" extensionOf="site" depends="verify" description="Builds a local directory that will reflect the structure of the final site with Ivy and Maven repositories as well as online API docs" >
|
|
<!-- First, creates an Ivy repo -->
|
|
<ivy:settings id="ivy.repo.site" file="${ivy.settings.path}" />
|
|
<!-- Note : transitive=false so we need to 'deploy' each project -->
|
|
<!-- Note : overwrite=true because it's easier during development -->
|
|
<!-- Example of final URL once tagged : http://ciform.googlecode.com/hg-history/1.0-SNAPSHOT/publications/nicommons/javascript/ivy.xml -->
|
|
<ivy:install organisation="${ivy.organisation}" module="${ivy.module}" revision="${ivy.revision}" settingsRef="ivy.repo.site" from="target" to="site" overwrite="true" />
|
|
<!-- Then add supplementary files -->
|
|
<copy todir="${pub.dir}/${ivy.organisation}/${ivy.module}">
|
|
<fileset dir="${basedir}">
|
|
<include name="*.txt" />
|
|
</fileset>
|
|
<!-- TODO copy pom
|
|
<fileset dir="${target.dir}">
|
|
<include name="*.pom" />
|
|
</fileset>
|
|
-->
|
|
</copy>
|
|
<copy todir="${pub.dir}/${ivy.organisation}/${ivy.module}/doc/api/js">
|
|
<fileset dir="${target.dir}/doc/api/js" />
|
|
</copy>
|
|
</target>
|
|
|
|
<target name="clean-site" description="Deletes the local site built with 'buils-site'">
|
|
<delete dir="${pub.dir}" includeemptydirs="true" deleteonexit="true" failonerror="false" />
|
|
</target>
|
|
|
|
|
|
<!--
|
|
MAVEN
|
|
-->
|
|
|
|
<!-- TODO Use the latest artifact:deploy plugin -->
|
|
<macrodef name="maven-deploy" description="Deploy artifact to Maven repository">
|
|
<attribute name="repositoryurl" />
|
|
<attribute name="repositoryid" />
|
|
<attribute name="pom" default="pom.xml" />
|
|
<attribute name="artifact" />
|
|
<attribute name="classifier" default="" />
|
|
<sequential>
|
|
<artifact:mvn if="@{classifier}">
|
|
<arg value="org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy-file" />
|
|
<arg value="-Durl=@{repositoryurl}" />
|
|
<arg value="-DrepositoryId=@{repositoryid}" />
|
|
<arg value="-DpomFile=@{pom}" />
|
|
<arg value="-Dfile=@{artifact}" />
|
|
<arg value="-Dclassifier=@{classifier}" />
|
|
<arg value="-Pgpg" />
|
|
</artifact:mvn>
|
|
<artifact:mvn unless="@{classifier}">
|
|
<arg value="org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy-file" />
|
|
<arg value="-Durl=@{repositoryurl}" />
|
|
<arg value="-DrepositoryId=@{repositoryid}" />
|
|
<arg value="-DpomFile=@{pom}" />
|
|
<arg value="-Dfile=@{artifact}" />
|
|
<arg value="-Pgpg" />
|
|
</artifact:mvn>
|
|
</sequential>
|
|
</macrodef>
|
|
|
|
<target name="sonatype-deploy-snapshot" description="Deploys a snapshot to Sonatype's Maven repository" >
|
|
<!-- TODO Use Ivy to retrieve artifacts list -->
|
|
<!-- The user must have the repository defined with this id in its settings -->
|
|
<local name="artifact" />
|
|
<local name="file.exists" />
|
|
|
|
<!-- main artifact -->
|
|
<property name="file" value="${target.lib.dir}/${ivy.module}.js" />
|
|
<available property="file.exists" file="${artifact}" />
|
|
<echo unless="file.exists" message="${artifact} does not exist : skipping publication." />
|
|
<mavendeploy if="file.exists" repositoryurl="https://oss.sonatype.org/content/repositories/snapshots/" repositoryid="sonatype-nexus-snapshots" pom="${target.dir}/${ivy.module}.pom" artifact="${artifact}" />
|
|
|
|
<!-- 'standalone' artifact -->
|
|
<property name="file" value="${target.lib.dir}/lib${ivy.module}.js" />
|
|
<available property="file.exists" file="${artifact}" />
|
|
<echo unless="file.exists" message="${artifact} does not exist : skipping publication." />
|
|
<mavendeploy if="file.exists" repositoryurl="https://oss.sonatype.org/content/repositories/snapshots/" repositoryid="sonatype-nexus-snapshots" pom="${target.dir}/${ivy.module}.pom" artifact="${artifact}" />
|
|
</target>
|
|
|
|
|
|
<!-- TEST ; not quite useful -->
|
|
<target name="ant2dot" description="(internal)" >
|
|
|
|
<!-- STEP 1: set some ANT properties -->
|
|
<property name="build.xml" value="${tools.dir}/build/ant-js.xml"/><!-- ie. this ANT script -->
|
|
<property name="ant2dot.xsl" value="${tools.dir}/build/ant2dot.xsl"/><!-- the stylesheet -->
|
|
<basename property="basename.script" file="${build.xml}" suffix=".xml"/>
|
|
<property name="dot.file" value="${build.dir}/${basename.script}.dot"/>
|
|
<property name="png.file" value="${target.dir}/${basename.script}.png"/>
|
|
|
|
<!-- STEP 2: generate the DOT file ("build.dot" or something similar) -->
|
|
<xslt in="${build.xml}" out="${dot.file}" style="${ant2dot.xsl}" force="true" />
|
|
|
|
<!-- STEP 3: generate the PNG file ("build.png" or something similar) -->
|
|
<exec executable="${tools.dir}/graphviz/bin/dot.exe">
|
|
<arg value="-Tpng"/>
|
|
<arg file="${dot.file}"/>
|
|
<arg value="-o"/>
|
|
<arg file="${png.file}"/>
|
|
</exec>
|
|
|
|
</target>
|
|
|
|
<!-- TEST ; not quite useful -->
|
|
<!--
|
|
<taskdef name="vizant" classname="net.sourceforge.vizant.Vizant" classpath="${tools.dir}/vizant-0.1.2.jar" description="(internal)" />
|
|
<target name="vizant">
|
|
<vizant antfile="${ant.file}" outfile="${build.dir}/build.dot"/>
|
|
<exec executable="${tools.dir}/graphviz/bin/dot.exe" >
|
|
<arg line="-Tpng"/>
|
|
<arg file="${build.dir}/build.dot"/>
|
|
<arg value="-o"/>
|
|
<arg file="${target.dir}/build.png"/>
|
|
</exec>
|
|
</target>
|
|
-->
|
|
|
|
<!--
|
|
TODO fix and integrate the following targets
|
|
-->
|
|
|
|
<target name="googlecode-upload" extensionOf="deploy" depends="verify" description="Uploads versionned artifacts to googlecode" >
|
|
<!-- TODO -->
|
|
</target>
|
|
|
|
<target name="pre-test" extensionOf="test" description="Runs unit tests">
|
|
<!-- 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-integration" extensionOf="integration-test" description="Runs integration tests" >
|
|
<!-- 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>
|
|
|
|
<!--
|
|
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="old-jsdoc" depends="validate">
|
|
|
|
<!-- Generates a report of dependencies -->
|
|
<ivy:report todir="${target.dir}/doc/ivy"/>
|
|
|
|
<!-- Generates the API doc -->
|
|
<exec command="${jsdoc}" failonerror="true">
|
|
<arg value="-d"/>
|
|
<arg value="${{target.dir}/doc/js"/>
|
|
<arg value="--no-lexical-privates"/>
|
|
<arg value="--package-naming"/>
|
|
<arg value="--nested-file-naming"/>
|
|
<arg line="--logo pix/ciform-flat-48x48.png" />
|
|
<arg line="--project-name Crypto.SHA1"/>
|
|
<arg value="${src.dir}"/>
|
|
</exec>
|
|
</target>
|
|
|
|
</project>
|