Permalink
Fetching contributors…
Cannot retrieve contributors at this time
207 lines (176 sloc) 7.46 KB
<project name="clojure-contrib" default="jar" xmlns:mvn="urn:maven-artifact-ant">
<description>
Pack all clojure-contrib sources into a JAR. Compile those that can
be compiled standalone if the clojure.jar property points us to
clojure.jar.
</description>
<property name="src" location="src"/>
<property name="build" location="classes"/>
<property file="local.properties"/>
<available property="hasclojure" file="${clojure.jar}"/>
<!-- The JAR file to create. -->
<property name="jarfile" location="clojure-contrib.jar"/>
<property name="slimjarfile" location="clojure-contrib-slim.jar"/>
<!-- These make sense for building on tapestry.formos.com -->
<property name="snapshot.repo.dir" location="/var/www/maven-snapshot-repository"/>
<property name="stable.repo.dir" location="/var/www/maven-repository"/>
<target name="init">
<tstamp/>
<mkdir dir="${build}"/>
</target>
<target name="clean" description="Remove generated files and directories.">
<delete file="${jarfile}"/>
<delete file="${slimjarfile}"/>
<delete dir="${build}"/>
</target>
<target name="test_contrib"
description="Run contrib tests"
if="hasclojure">
<java classname="clojure.main" fork="true">
<classpath>
<path location="${build}"/>
<path location="${src}"/>
<path location="${clojure.jar}"/>
</classpath>
<arg value="-e"/>
<arg value="(require '(clojure.contrib [test-contrib :as main])) (main/run)"/>
<jvmarg value="-Djava.security.policy=config/jmx.policy"/>
</java>
</target>
<target name="test_datalog"
description="Run datalog tests"
if="hasclojure">
<java classname="clojure.main">
<classpath>
<path location="${build}"/>
<path location="${src}"/>
<path location="${clojure.jar}"/>
</classpath>
<arg value="-e"/>
<arg value="(require '(clojure.contrib.datalog.tests [test :as main])) (main/run)"/>
</java>
</target>
<target name="test" depends="test_contrib,test_datalog"
description="Run all tests"/>
<target name="check_hasclojure"
description="Print a warning message if clojure.jar is undefined"
unless="hasclojure">
<echo>WARNING: You have not defined a path to clojure.jar so I can't compile files.
This will cause some parts of clojure.contrib not to work (e.g., pretty print).
To enable compiling, run "ant -Dclojure.jar=&lt;...path to clojure.jar..&gt;"
</echo>
</target>
<target name="compile_classes" depends="init,check_hasclojure"
description="Compile the clojure files that have gen-class."
if="hasclojure">
<java classname="clojure.lang.Compile">
<classpath>
<path location="${build}"/>
<path location="${src}"/>
<path location="${clojure.jar}"/>
</classpath>
<sysproperty key="clojure.compile.path" value="${build}"/>
<arg value="clojure.contrib.pprint.ColumnWriter"/>
<arg value="clojure.contrib.pprint.PrettyWriter"/>
<arg value="clojure.contrib.fnmap.PersistentFnMap"/>
<arg value="clojure.contrib.condition.Condition"/>
<arg value="clojure.contrib.jmx.Bean"/>
</java>
</target>
<target name="compile_clojure" depends="init,check_hasclojure,compile_classes"
description="Compile Clojure sources."
if="hasclojure">
<!-- Seek out the namespaces to compile. Note that this will fail if the actual name of a package includes an underscore, as
all underscores are converted to dashes. -->
<echo>Locating namespaces to compile ...</echo>
<pathconvert pathsep=" " property="compile.namespaces">
<fileset dir="${src}" includes="**/*.clj">
<!-- TODO: Seperate out the source into at least three root folders: one for namespaces with :gen-class, one for
ordinary namespaces (to be AOT compiled) and one for test namespaces (which, perhaps, should not be included
in the packaged JAR).
Complicated exclude rules like this are a bad design smell for the build.xml and/or project layout.
-->
<exclude name="**/*_test.clj" />
<exclude name="**/test_*/**" />
<exclude name="clojure/contrib/javadoc.clj" />
<exclude name="clojure/contrib/jmx/*.clj" />
<exclude name="**/pprint/**"/>
<exclude name="**/with_pull.clj" />
<exclude name="**/examples*/**" />
<exclude name="**/PersistentFnMap.clj" />
<exclude name="**/Condition.clj" />
<exclude name="**/Bean.clj" />
<exclude name="**/repl_utils/javadoc.clj"/>
<exclude name="clojure/contrib/load_all.clj"/>
<exclude name="**/tests.clj"/>
<exclude name="clojure/contrib/logging.clj"/>
</fileset>
<chainedmapper>
<packagemapper from="${src}/*.clj" to="*" />
<filtermapper>
<replacestring from="_" to="-" />
</filtermapper>
</chainedmapper>
</pathconvert>
<echo>Compiling Clojure namespaces ...</echo>
<java classname="clojure.lang.Compile">
<classpath>
<path location="${build}"/>
<path location="${src}"/>
<path location="${clojure.jar}"/>
</classpath>
<sysproperty key="clojure.compile.path" value="${build}"/>
<sysproperty key="java.awt.headless" value="true"/>
<arg line="${compile.namespaces}" />
</java>
</target>
<target name="jar" description="Create jar files." depends="compile_clojure">
<jar jarfile="${jarfile}">
<fileset file="epl-v10.html"/>
<fileset dir="${src}" includes="**/*.clj"/>
<fileset dir="${build}" includes="**/*.class"/>
<manifest>
<attribute name="Class-Path" value="."/>
</manifest>
</jar>
<jar jarfile="${slimjarfile}">
<fileset file="epl-v10.html"/>
<fileset dir="${src}" includes="**/*.clj"/>
<manifest>
<attribute name="Class-Path" value="."/>
</manifest>
</jar>
</target>
<target name="-setup-maven" description="Load Maven typedefs, read POM, establish dependencies.">
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant"/>
<mvn:pom file="pom.xml" id="contrib.pom"/>
<mvn:dependencies pomRefId="contrib.pom"/>
</target>
<target name="clean-build" depends="clean,compile_clojure,test,jar"
description="Builds clojure-contrib from scratch and runs all tests."/>
<target name="ci-build" depends="-setup-maven"
description="Build clojure-contrib using Clojure obtained via Maven.">
<antcall target="clean-build">
<param name="clojure.jar" value="${org.clojure:clojure-lang:jar}"/>
</antcall>
<mvn:install file="${jarfile}" pomrefid="contrib.pom">
<attach file="${slimjarfile}" classifier="slim"/>
</mvn:install>
</target>
<macrodef name="deploy">
<attribute name="target-dir" description="Root of Maven repository"/>
<sequential>
<mvn:deploy file="${jarfile}" pomrefid="contrib.pom">
<attach file="${slimjarfile}" classifier="slim"/>
<remoteRepository url="file:@{target-dir}"/>
</mvn:deploy>
</sequential>
</macrodef>
<target name="nightly-build" depends="ci-build"
description="Build and deploy to nightly (snapshot) repository.">
<deploy target-dir="${snapshot.repo.dir}"/>
</target>
<target name="stable-build" depends="ci-build" description="Build and deploy to stable repository.">
<deploy target-dir="${stable.repo.dir}"/>
</target>
</project>