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

<project name='standard' basedir='.' default='none'>

	<!-- default properties, set before including this file to use custom values -->

	<property name='javac.debug' value='true' />
	<property name='javac.deprecation' value='true' />
	<property name='javac.version' value='1.5' />

	<property name='test.haltonfailure' value='true' />
	<property name='test.haltonerror' value='true' />

	<property name='dir.build' value='build' />
	<property name='dir.src' value='src' />
	<property name='dir.test' value='test' />
	<property name='dir.javadoc' value='${dir.build}/javadoc' />

	<property name='dir.classes.src' value='${dir.build}/classes' />
	<property name='dir.classes.test' value='${dir.build}/test/classes' />
	<property name='dir.testresult' value='${dir.build}/test/result' />
	<property name='dir.generated.hibernate' value='${dir.build}/generated/hibernate' />

	<!-- Presetdefs -->

	<presetdef name='def.copy'>
		<copy
			preservelastmodified='true'
			includeEmptyDirs='false' />
	</presetdef>

	<presetdef name='def.javac'>
		<javac
			debug='${javac.debug}'
			deprecation='${javac.deprecation}'
			source='${javac.version}'
			target='${javac.version}'/>
	</presetdef>

	<presetdef name='def.junit'>
		<junit
			fork='true'
			haltonfailure='${test.haltonfailure}'
			haltonerror='${test.haltonerror}'
			printsummary='true'>
			<formatter type='plain' usefile='false' />
			<formatter type='xml' />
		</junit>
	</presetdef>

	<presetdef name='def.javadoc'>
		<javadoc
			destdir='${dir.javadoc}'
			classpathref='classpath.libdir'
			maxmemory='256m'
			packagenames='com.burtbeckwith.*'
			access='package'
			source='${javac.version}'
			use='true'
			notree='false'
			nonavbar='false'
			noindex='false'
			splitindex='true'
			author='true'
			nodeprecatedlist='false'
			nodeprecated='false'
			sourcepath='${dir.src}'
			breakiterator='true'
			version='true'>

			<tag name='hibernate.class' enabled='false'/>
			<tag name='hibernate.collection-element' enabled='false'/>
			<tag name='hibernate.collection-index' enabled='false'/>
			<tag name='hibernate.collection-key' enabled='false'/>
			<tag name='hibernate.collection-many-to-many' enabled='false'/>
			<tag name='hibernate.collection-one-to-many' enabled='false'/>
			<tag name='hibernate.id' enabled='false'/>
			<tag name='hibernate.index-many-to-many' enabled='false'/>
			<tag name='hibernate.joined-subclass' enabled='false'/>
			<tag name='hibernate.joined-subclass-key' enabled='false'/>
			<tag name='hibernate.list' enabled='false'/>
			<tag name='hibernate.many-to-many' enabled='false'/>
			<tag name='hibernate.many-to-one' enabled='false'/>
			<tag name='hibernate.map' enabled='false'/>
			<tag name='hibernate.property' enabled='false'/>
			<tag name='hibernate.set' enabled='false'/>

			<tag name='web.filter' enabled='false'/>
			<tag name='web.filter-mapping' enabled='false'/>
			<tag name='web.listener' enabled='false'/>

			<link href='http://java.sun.com/j2se/1.5.0/docs/api/' />
			<link href='http://www.junit.org/junit/javadoc/3.8.1/' />
			<link href='http://logging.apache.org/log4j/docs/api/' />

		</javadoc>
	</presetdef>

	<!-- macrodefs -->

	<macrodef name='unitTest'>
		<attribute name='maxMemory' default='-Xmx256m'/>
		<attribute name='report.dir' />
		<element name='filesets' optional='false' />
		<element name='classpathElements' optional='false' />
		<sequential>

			<def.junit>

				<classpath>
					<classpathElements />
				</classpath>

				<jvmarg value='@{maxMemory}' />

				<batchtest todir='@{report.dir}'>
					<filesets />
				</batchtest>
			</def.junit>

			<junitreport todir='@{report.dir}'>
				<fileset dir='@{report.dir}'>
					<include name='TEST-*.xml' />
				</fileset>
				<report format='frames' todir='@{report.dir}' />
			</junitreport>

		</sequential>
	</macrodef>

	<macrodef name='xdocletHibernate'>
		<element name='classpathElements' optional='false' />
		<element name='filesets' optional='false' />

		<sequential>

			<taskdef
				name='hibernatedoclet'
				classname='xdoclet.modules.hibernate.HibernateDocletTask'>
				<classpath>
					<classpathElements />
				</classpath>
			</taskdef>

			<delete dir='${dir.generated.hibernate}' />

			<hibernatedoclet
				destdir='${dir.generated.hibernate}'
				excludedtags='@version,@author,@todo'
				force='false'
				mergedir='merge'
				verbose='false'>

				<filesets />
		
				<hibernate version='3.0' />
		
			</hibernatedoclet>

			<def.copy todir='${dir.classes.src}'>
				<fileset dir='${dir.generated.hibernate}' includes='**/*.hbm.xml' />
			</def.copy>

		</sequential>
	</macrodef>

	<macrodef name='schema'>
		<attribute name='quiet' />
		<attribute name='text' />
		<attribute name='output' />
		<attribute name='drop' />
		<element name='filesets' optional='false' />

		<sequential>

			<taskdef
				name='schemaexport'
				classpathref='classpath.withclasses'
				classname='org.hibernate.tool.hbm2ddl.SchemaExportTask' />

			<schemaexport
				quiet='@{quiet}'
				text='@{text}'
				drop='@{drop}'
				delimiter=';'
				output='@{output}'>

				<filesets />

			</schemaexport>

		</sequential>
	</macrodef>

	<!-- paths -->
	<path id='classpath.libdir'>
		<fileset dir='lib'>
			<include name='**/*.jar' />
		</fileset>
	</path>

	<path id='classpath.withclasses'>
		<path refid='classpath.libdir' />
		<pathelement location='${dir.classes.src}' />
	</path>

	<path id='classpath.test'>
		<path refid='classpath.withclasses' />
	</path>

	<!-- targets -->

	<!-- dummy for dependency resolution, override in containing build.xml -->
	<target name='init.dependencies'/>

	<target name='check.javadoc.uptodate'>
		<uptodate
			property='javadoc.uptodate'
			targetfile='${dir.javadoc}/index.html'>
			<srcfiles dir='${dir.src}' includes='**/*.java' />
		</uptodate>
	</target>

	<target name='prepare' depends='init.dependencies'>
		<tstamp/>
		<mkdir dir='${dir.classes.src}' />
		<mkdir dir='${dir.generated.hibernate}' />
	</target>

	<!-- copy XML, etc. files into classpath -->
	<target
		name='copy.resources'
		depends='prepare'>

		<def.copy todir='${dir.classes.src}'>
			<fileset dir='${dir.src}' excludes='**/*.java'/>
		</def.copy>
	</target>

	<target
		name='def.clean'
		description='cleans up build files and directories'>

		<delete dir='${dir.build}' />
	</target>

	<target
		name='def.compile.java'
		depends='copy.resources'>

		<def.javac
			srcdir='${dir.src}'
			destdir='${dir.classes.src}'
			classpathref='classpath.libdir' />

	</target>

	<target
		name='def.compile.tests'
		depends='def.compile.java'>

		<delete dir='${dir.classes.test}'/>
		<mkdir dir='${dir.classes.test}'/>

		<def.javac
			srcdir='test'
			destdir='${dir.classes.test}'
			classpathref='classpath.test'/>

		<def.copy todir='${dir.classes.test}'>
			<fileset dir='${dir.test}' excludes='**/*.java'/>
		</def.copy>

	</target>

	<!-- dummy for dependency checks, override if needed -->
	<target name='xdoclet.hibernate' />

	<target
		name='def.test'
		depends='def.clean, xdoclet.hibernate, def.compile.tests'
		description='run all unit tests'>

		<delete dir='${dir.testresult}'/>
		<mkdir dir='${dir.testresult}'/>

		<unitTest report.dir='${dir.testresult}'>
			<filesets>
				<fileset dir='${dir.test}'>
					<include name='**/*Test.java'/>
					<exclude name='**/Base*Test.java'/>
				</fileset>
			</filesets>
			<classpathElements>
				<path refid='classpath.test'/>
				<pathelement location='${dir.classes.test}'/>
			</classpathElements>
		</unitTest>

	</target>

</project>


