<?xml version="1.0"?>
<project name="hyperjaxb2-sample-ant" default="install">
	<property name="artifactId" value="hyperjaxb2-template-basic-ant"/>
	<property name="version" value="0.6.2"/>
	<path id="hyperjaxb2.compile.path">
		<pathelement path="${basedir}/classes"/>
		<fileset dir="${basedir}/lib">
			<include name="jaxb-xjc-*.jar"/>
			<include name="jaxb-impl-*.jar"/>
			<include name="isorelax-*.jar"/>
			<include name="jaxb-api-*.jar"/>
			<include name="jaxb-libs-*.jar"/>
			<include name="jaxp-api-*.jar"/>
			<include name="jaxp-ri-*.jar"/>
			<include name="relaxngDatatype-*.jar"/>
			<include name="xsdlib-*.jar"/>
			<include name="jaxbcommons-core-*.jar"/>
			<include name="jaxbcommons-shared-*.jar"/>
			<include name="jaxbcommons-testing-*.jar"/>
			<include name="spring-*.jar"/>
			<include name="hyperjaxb2-core-*.jar"/>
			<include name="hyperjaxb2-hibernate-configuration-*.jar"/>
			<include name="hyperjaxb2-hibernate-customizations-*.jar"/>
			<include name="hyperjaxb2-hibernate-mapping-*.jar"/>
			<include name="hyperjaxb2-shared-*.jar"/>
			<include name="hyperjaxb2-testing-*.jar"/>
			<include name="commons-lang-*.jar"/>
			<include name="commons-logging-*.jar"/>
			<include name="commons-beanutils-*.jar"/>
			<include name="log4j-*.jar"/>
			<include name="saxon-*.jar"/>
			<include name="saxon-dom-*.jar"/>
			<include name="hibernate-*.jar"/>
			<include name="junit-*.jar"/>
		</fileset>
	</path>
	<path id="hyperjaxb2.runtime.path">
		<fileset dir="${basedir}/lib">
			<include name="antlr-*.jar"/>
			<include name="asm-*.jar"/>
			<include name="asm-attrs-*.jar"/>
			<include name="cglib-*.jar"/>
			<include name="ehcache-*.jar"/>
			<include name="jta-*.jar"/>
			<include name="hibernate-*.jar"/>
			<include name="dom4j-*.jar"/>
			<include name="commons-collections-*.jar"/>
			<include name="commons-io-*.jar"/>
			<include name="commons-lang-*.jar"/>
			<include name="jaxb-api-*.jar"/>
			<include name="jaxb-impl-*.jar"/>
			<include name="jaxp-api-*.jar"/>
			<include name="jaxp-ri-*.jar"/>
			<include name="isorelax-*.jar"/>
			<include name="jaxb-libs-*.jar"/>
			<include name="relaxngDatatype-*.jar"/>
			<include name="xsdlib-*.jar"/>
			<include name="jaxbcommons-shared-*.jar"/>
			<include name="jaxbcommons-testing-*.jar"/>
			<include name="hyperjaxb2-shared-*.jar"/>
			<include name="hyperjaxb2-testing-*.jar"/>
			<include name="commons-logging-*.jar"/>
			<include name="log4j-*.jar"/>
			<include name="hsqldb-*.jar"/>
			<include name="junit-*.jar"/>
		</fileset>
	</path>
	<target name="clean">
		<delete dir="${basedir}/target/"/>
		<delete dir="${basedir}/target/classes"/>
		<delete dir="${basedir}/target/test-classes"/>
	</target>
	<target name="generate-sources">
		<taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask" classpathref="hyperjaxb2.compile.path"/>
		<mkdir dir="${basedir}/target/generated-sources/xjc"/>
		<xjc target="${basedir}/target/generated-sources/xjc" extension="true">
			<arg line="
				-Xequals
				-XhashCode
				-Xhyperjaxb2
				-Xhyperjaxb2-rt=RoundtripTest"/>
			<binding dir="${basedir}/src/main/resources">
			 	<include name="**/*.xjb"/>
			</binding>
			<schema dir="${basedir}/src/main/resources">
			 	<include name="**/*.xsd"/>
			</schema>
		</xjc>
	</target>
	<target name="compile" depends="generate-sources">
		<mkdir dir="${basedir}/target/classes"/>
		<javac
			destdir="${basedir}/target/classes" 
			srcdir="${basedir}/src/main/java:${basedir}/target/generated-sources/xjc"
			classpathref="hyperjaxb2.compile.path">
		</javac>
		<copy todir="${basedir}/target/classes">
			<fileset dir="${basedir}/src/main/resources"/>
			<fileset dir="${basedir}/target/generated-sources/xjc">
				<exclude name="**/*.java" />
			</fileset>
		</copy>
	</target>
	<target name="test-compile" depends="compile">
		<mkdir dir="${basedir}/target/test-classes"/>
		<javac
			destdir="${basedir}/target/test-classes" 
			srcdir="${basedir}/src/test/java:${basedir}/target/generated-sources/xjc"
			classpathref="hyperjaxb2.runtime.path">
		</javac>
		<copy todir="${basedir}/target/test-classes">
			<fileset dir="${basedir}/src/test/resources"/>
			<fileset dir="${basedir}/target/generated-sources/xjc">
				<exclude name="**/*.java" />
			</fileset>
		</copy>
	</target>
	<target name="test" depends="test-compile">
		<mkdir dir="${basedir}/target/junit-reports"/>
		<junit printsummary="yes" haltonfailure="yes">
			<classpath>
				<pathelement location="${basedir}/target/classes"/>
				<pathelement location="${basedir}/target/test-classes"/>
				<path refid="hyperjaxb2.runtime.path"/>
			</classpath>

			<formatter type="plain"/>
			<formatter type="xml"/>

			<batchtest fork="yes" todir="${basedir}/target/junit-reports">
				<fileset dir="${basedir}/src/test/java">
					<include name="**/*Test*.java"/>
					<exclude name="**/AllTests.java"/>
				</fileset>
				<fileset dir="${basedir}/target/generated-sources/xjc">
					<include name="**/*Test*.java"/>
					<exclude name="**/AllTests.java"/>
				</fileset>
			</batchtest>
		</junit>
	</target>
	<target name="package" depends="test">
		<mkdir dir="${basedir}/target"/>
		<jar destfile="${basedir}/target/${artifactId}-${version}.jar"
			basedir="${basedir}/target/classes"/> 
	</target>
	<target name="install" depends="package"/>
</project>