<?xml version="1.0"?>
<!--
$Revision: 1.80 $
$Date: 2008/08/23 10:08:08 $
$Author: billhorsman $
http://proxool.sourceforge.net
-->
<project name="Proxool" default="build-jar" basedir=".">
<!-- Use this to avoid having to pass properties in the command line -->
<property file="proxool-ant.properties"/>
<!-- Whether to include the test classes -->
<property name="test" value="false"/>
<!-- Whether to include the sandbox classes -->
<property name="sandbox" value="false"/>
<!-- Where to build everything. You might want to override
this so that it isn't within your cvs tree. -->
<property name="build-dir" value="build"/>
<!-- Whether we include debug information in JAR file -->
<property name="debug" value="true"/>
<!-- Currect release, e.g. 0.6 -->
<property name="release" value="0.9.1"/>
<!-- Currect release, e.g. 0.6 -->
<property name="junit-report-description" value="Unit Test Report for CVS Snapshot"/>
<!-- Currect release, e.g. 0.6 -->
<property name="junit-report-name" value="junit-cvs.html"/>
<!-- Log4J configuration to use for testing. See proxool-ant.properties
file for more infomation. -->
<property name="log4jPath" value="src/java-test/org/logicalcobwebs/proxool/log4j-test.xml"/>
<!-- Passed to JVM when running tests -->
<property name="jvmargs" value=""/>
<!-- What test suite to run when calling the "test" target -->
<property name="test-suite" value="org.logicalcobwebs.proxool.GlobalTest"/>
<!-- Classpath -->
<path id="source" path="${build-dir}/classes">
<fileset dir="lib">
<include name="**/*.jar"/>
<include name="**/*.zip"/>
</fileset>
<path path="build/lib/proxool-cglib.jar"/>
</path>
<path id="binary">
<fileset dir="lib">
<include name="**/*.jar"/>
<include name="**/*.zip"/>
</fileset>
<fileset dir="jar">
<include name="**/*.jar"/>
</fileset>
</path>
<taskdef name="checkstyle" classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
<classpath refid="source"/>
</taskdef>
<!--
Build necessary directories
-->
<target
name="init"
>
<tstamp>
<format property="TODAY_FULL" pattern="dd-MMM-yyyy HH:mm zzz"/>
</tstamp>
<mkdir dir="${build-dir}/src/java" description="make source directory"/>
<mkdir dir="${build-dir}/etc"/>
<mkdir dir="${build-dir}/deploy"/>
<mkdir dir="${build-dir}/classes"/>
<mkdir dir="${build-dir}/api"/>
<mkdir dir="${build-dir}/api-dev"/>
<mkdir dir="${build-dir}/reports"/>
<available classname="junit.ui.TestRunner" property="junit.present"/>
</target>
<target
name="evaluate-properties"
description="Works out what elements we should include in the build"
>
<!--
Evaluate whether we should build the source code
with test classes
-->
<condition property="build-test">
<equals arg1="${test}" arg2="true"/>
</condition>
<!--
Evaluate whether we should build the source code
using the experimental stuff in the sandbox
-->
<condition property="build-sandbox">
<equals arg1="${sandbox}" arg2="true"/>
</condition>
</target>
<target
name="clean"
description="Cleans build directory"
>
<delete dir="${build-dir}"/>
</target>
<target
name="deleteTestDb"
description="Cleans build directory"
>
<delete dir="db"/>
</target>
<target
name="checkstyle"
description="Checks Java code for style"
>
<checkstyle>
<fileset dir="src/java" includes="**/*.java" excludes="**/concurrent/*,**/asm/**,**/cglib/**"/>
<fileset dir="src/java-examples" includes="**/*.java"/>
<fileset dir="src/java-sandbox" includes="**/*.java"/>
<fileset dir="src/java-test" includes="**/*.java"/>
<property key="checkstyle.require.version" value="true"/>
<property key="checkstyle.javadoc.scope" value="nothing"/>
<property key="checkstyle.maxlinelen" value="200"/>
<property key="checkstyle.tab.width" value="4"/>
</checkstyle>
</target>
<target
name="strict-checkstyle"
description="Checks Java code for style (we don't enforce this strictness, yet)"
>
<checkstyle>
<fileset dir="src/java" includes="**/*.java"/>
<fileset dir="src/java-examples" includes="**/*.java"/>
<fileset dir="src/java-sandbox" includes="**/*.java"/>
<fileset dir="src/java-test" includes="**/*.java"/>
<property key="checkstyle.require.version" value="true"/>
<property key="checkstyle.javadoc.scope" value="protected"/>
<property key="checkstyle.maxlinelen" value="200"/>
<property key="checkstyle.tab.width" value="4"/>
</checkstyle>
</target>
<target
name="build-src"
description="Gathers the source code together ready for compiling"
depends="clean,init,evaluate-properties"
>
<antcall target="build-src-core"/>
<antcall target="build-src-test"/>
<antcall target="build-src-sandbox"/>
<antcall target="version-stamp"/>
</target>
<target
name="version-stamp"
description="Adds the version and build date to the Version class"
if="version"
>
<replace
file="${build-dir}/src/java/org/logicalcobwebs/proxool/Version.java"
token="VERSION = null"
value='VERSION = "${release}"'
/>
<replace
file="${build-dir}/src/java/org/logicalcobwebs/proxool/Version.java"
token="BUILD_DATE = null"
value='BUILD_DATE = "${TODAY}"'
/>
</target>
<target
name="compile"
description="Compiles the code"
depends="init,build-src,repackage-dependencies"
>
<javac srcdir="${build-dir}/src/java" target="1.2" source="1.2" destdir="${build-dir}/classes" debug="${debug}">
<classpath refid="source"/>
<classpath path="build/proxool-cglib.jar"/>
</javac>
<!-- Copy dtd's and properties into the compiled classes directory. -->
<copy todir="${build-dir}/classes">
<fileset dir="src/java" includes="**/*.dtd"/>
<fileset dir="src/java" includes="**/*.properties"/>
</copy>
</target>
<target
name="build-jar"
description="Compiles and builds the JAR file"
depends="init,build-src,compile"
>
<manifest file="${build-dir}/etc/MANIFEST.MF">
<attribute name="Proxool-Version" value="${release}"/>
<attribute name="Date" value="${TODAY}"/>
</manifest>
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="jarjar/jarjar-0.6.jar"/>
<jarjar
verbose="true"
jarfile="${build-dir}/proxool-${release}.jar"
basedir="${build-dir}/classes"
manifest="${build-dir}/etc/MANIFEST.MF">
<zipfileset src="jarjar/cglib-nodep-2.1_3.jar"/>
<rule pattern="net.sf.cglib.**" result="org.logicalcobwebs.cglib.@1"/>
<zap pattern="net.sf.cglib.transform.**"/>
<zap pattern="net.sf.cglib.beans.**"/>
<zap pattern="net.sf.cglib.util.**"/>
</jarjar>
</target>
<target
name="build-src-core"
depends="init"
description="Build the core source (all that is required to run Proxool)"
>
<echo level="info" message="Using ${java.vm.vendor} ${java.vm.name} ${java.vm.version} in ${java.home}"/>
<copy todir="${build-dir}/src/java" preservelastmodified="yes">
<fileset dir="src/java" includes="**/*.java"/>
<fileset dir="src/java" includes="**/*.dtd"/>
</copy>
</target>
<target
name="build-src-sandbox"
depends="init"
description="Build the source for the experimental sandbox tree"
if="build-sandbox"
>
<echo level="info" message="Using Sandbox"/>
<copy todir="${build-dir}/src/java" preservelastmodified="yes">
<fileset dir="src/java-sandbox" includes="**/*.java"/>
</copy>
</target>
<target
name="build-src-test"
depends="init"
description="Build the source for testing"
if="build-test"
>
<echo level="verbose" message="Collecting test classes"/>
<copy todir="${build-dir}/src/java">
<fileset dir="src/java-test" includes="**/*.java"/>
</copy>
</target>
<target
name="build-test"
depends="init"
>
<property name="build-test" value="true"/>
<antcall target="build-src"/>
<antcall target="repackage-dependencies"/>
<antcall target="compile"/>
<copy todir="${build-dir}/classes">
<fileset dir="src/java-test" includes="**/*.properties,**/*.xml"/>
</copy>
</target>
<target
name="test"
description="Runs the JUnit tests"
depends="clean,init,build-test,deleteTestDb"
>
<java fork="yes" classpathref="source" classname="junit.textui.TestRunner" >
<sysproperty key="log4jPath" value="${log4jPath}"/>
<arg value="${test-suite}"/>
<jvmarg line="${jvmargs}"/>
</java>
<echo message="Note! These unit tests have probably produced some worrying exceptions. As long as the tests passed then you can ignore these exceptions. They are part of the tests."/>
</target>
<target name="repackage-dependencies" description="Repackage the Cglib project into Proxool">
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="jarjar/jarjar-0.6.jar"/>
<mkdir dir="build/lib"/>
<jarjar verbose="false" jarfile="build/lib/proxool-cglib.jar">
<zipfileset src="jarjar/cglib-nodep-2.1_3.jar"/>
<rule pattern="net.sf.cglib.**" result="org.logicalcobwebs.cglib.@1"/>
</jarjar>
</target>
<target
name="produce-test-report"
description="Produce a report of the tests"
depends="clean,init,build-test,deleteTestDb"
>
<junit fork="true" printsummary="yes">
<classpath refid="source"/>
<sysproperty key="log4jPath" value="${log4jPath}"/>
<batchtest todir="${build-dir}/reports">
<fileset dir="src/java-test"
includes="**/*Test.java"
excludes="**/GlobalTest.java,**/Abstract*,**/PerformanceTest.java"
/>
</batchtest>
<formatter type="xml"/>
</junit>
<junitreport>
<fileset dir="${build-dir}/reports">
<include name="TEST-*.xml"/>
</fileset>
<report format="noframes" todir="${build-dir}/reports"/>
</junitreport>
<move
file="${build-dir}/reports/junit-noframes.html"
tofile="${build-dir}/reports/${junit-report-name}"/>
<replace
file="${build-dir}/reports/${junit-report-name}"
token="<h1>Unit Test Results</h1>"
value=""
/>
<replace
file="${build-dir}/reports/${junit-report-name}"
token="68%"
value="100%"
/>
<replace
file="${build-dir}/reports/${junit-report-name}"
token='Designed for use with <a href="http://www.junit.org">JUnit</a> and <a href="http://jakarta.apache.org/ant">Ant</a>.'
value='${TODAY_FULL}'
/>
</target>
<target
name="javadoc"
description="Produce Javadoc API for users"
depends="init">
<javadoc
sourcepath="src/java"
destdir="${build-dir}/api"
packagenames="org.logicalcobwebs.proxool,org.logicalcobwebs.proxool.configuration"
doctitle="Proxool API}"
windowtitle="Proxool API}"
public="true"
/>
<!-- Copy dtd's over to the doc. -->
<copy todir="${build-dir}/api">
<fileset dir="src/java" includes="**/*.dtd"/>
</copy>
</target>
<target
name="javadoc-dev"
description="Produce Javadoc API for developers"
depends="init">
<javadoc
destdir="${build-dir}/api-dev"
packagenames="org.logicalcobwebs.*"
doctitle="Proxool Developer's API}"
windowtitle="Proxool Developer's API}"
private="true"
>
<sourcepath path="src/java"/>
<sourcepath path="src/java-test"/>
<sourcepath path="src/java-sandbox"/>
</javadoc>
<!-- Copy dtd's over to the doc. -->
<copy todir="${build-dir}/api-dev">
<fileset dir="src/java" includes="**/*.dtd"/>
</copy>
</target>
<target
name="source-version"
description="Outputs the source version"
depends="init,compile"
>
<java classpathref="source" classname="org.logicalcobwebs.proxool.Version"/>
</target>
<target
name="binary-version"
description="Outputs the source version"
depends="init"
>
<java classpathref="binary" classname="org.logicalcobwebs.proxool.Version"/>
</target>
</project>