<?xml version="1.0" encoding="UTF-8"?>

<project name="db4o" default="jar" basedir=".">
	<description>
		DB4O doesn't provide a decent building script... here is the one we are going to use.
	</description>

	<!-- set global properties for this build -->
	<property name="src" location="src"/>
	<property name="build" location="build"/>
	<property name="build-db4oj" location="build-db4oj"/>
	<property name="build-db4ojdk1.2" location="build-db4ojdk1.2"/>
	<property name="build-db4ojdk5" location="build-db4ojdk5"/>
	<property name="jarfile" location="db4o.jar"/>
	<property name="javac.target.version" value="1.5"/>

	<assertions>
		<enable/>
	</assertions>

	<target name="mkdir">
		<mkdir dir="${build}"/>
		<mkdir dir="${build-db4oj}"/>
		<mkdir dir="${build-db4ojdk1.2}"/>
		<mkdir dir="${build-db4ojdk5}"/>
	</target>

	<!-- ================================================== -->

	<target name="compile" depends="mkdir">
		<!-- Create the time stamp -->
		<tstamp/>

		<javac srcdir="${src}" destdir="${build-db4oj}" debug="on" optimize="on" source="${javac.target.version}">
			<classpath>
				<pathelement location="${freenet-ext.location}"/>
			</classpath>

			<include name="db4oj/**/*.java"/>
			<exclude name="db4oj/test/**/*.java"/>
		</javac>

		<javac srcdir="${src}" destdir="${build-db4ojdk1.2}" debug="on" optimize="on" source="${javac.target.version}">
			<classpath>
				<pathelement location="${build-db4oj}"/>
			</classpath>

			<include name="db4ojdk1.2/**/*.java"/>
			<exclude name="db4ojdk1.2/test/**/*.java"/>
		</javac>

		<javac srcdir="${src}" destdir="${build-db4ojdk5}" debug="on" optimize="on" source="${javac.target.version}">
			<classpath>
				<pathelement location="${build-db4oj}"/>
				<pathelement location="${build-db4ojdk1.2}"/>
			</classpath>

			<include name="db4ojdk5/**/*.java"/>
			<exclude name="db4ojdk5/test/**/*.java"/>
		</javac>
	</target>

	<!-- ================================================== -->

	<target name="mergeOptimizations" depends="compile">
		<!-- yes, order matters! -->
		<copy todir="${build}/" overwrite="true">
			<fileset dir="${build-db4oj}"/>
		</copy>
		<copy todir="${build}/" overwrite="true">
			<fileset dir="${build-db4ojdk1.2}"/>
		</copy>
		<copy todir="${build}/" overwrite="true">
			<fileset dir="${build-db4ojdk5}"/>
		</copy>
	</target>

	<!-- ================================================== -->

	<target name="jar" depends="compile, mergeOptimizations"
		description="generate the distribution" >
		<!-- Create the distribution directory -->
		<jar jarfile="${jarfile}" basedir="${build}"/>
	</target>

	<!-- ================================================== -->

	<target name="clean" description="Delete class files and docs dir.">
		<delete file="${jarfile}"/>
		<delete dir="${build}"/>
		<delete dir="${build-db4oj}"/>
		<delete dir="${build-db4ojdk1.2}"/>
		<delete dir="${build-db4ojdk5}"/>
	</target>
</project>
