<?xml version="1.0"?>
<!--
	Build file for Tahiti
-->
<project name="tahiti" basedir="." default="binary">
	
	<!-- import the global configuration file -->
	<property file="../shared/ant.config"/>
	
	
	
	<!-- compile Java source files -->
	<target name="binary">
		<mkdir dir="./bin"/>
		<javac
			srcdir="./src:./test"
			destdir="./bin"
			debug="on"
			optimize="off">
			
			<classpath path="../msv/bin" />
			<classpath path="../xsdlib/bin" />
			<classpath path="../testharness/bin" />
		</javac>
	</target>
	
	
	
	<!-- create a distribution package -->
	<target name="release">
		<tstamp />
		<property name="stageName" value="tahiti-${DSTAMP}"/>
		
		<delete	dir="${stageName}" />
		<mkdir	dir="${stageName}/src" />
		
		<!-- obtain source codes from cvs -->
		<cvs	cvsRoot="${cvsRoot}"
				package="msv/tahiti/src"
				command="export -d src -D now"
				dest="${stageName}" />
		<cvs	cvsRoot="${cvsRoot}"
				package="msv/tahiti/doc"
				command="export -d ${stageName} -D now"
				dest="." />
		<fixcrlf	srcdir="${stageName}"
					cr="remove"
					eof="remove"
					includes="*.txt"/>
		
		<!-- compile documents -->
		<style basedir="${stageName}" destdir="${stageName}" extension=".html"
				style="./tahiti.xsl" includes="*.docbook"/>
		
		<!-- then remove docbook source -->
		<delete>
			<fileset dir="${stageName}">
				<include name="*.docbook"/>
				<include name="*.xsl"/>
			</fileset>
		</delete>
		
		
		<!-- compile runtime files -->
		<mkdir	dir="temp" />
		<javac	srcdir="${stageName}/src" destdir="temp">
			<classpath path="../package/msv.jar"/>
			<classpath path="../package/xsdlib.jar"/>
			
			<include name="com/sun/tahiti/runtime/**/*.java" />
		</javac>
		
		<!-- create a time stamp file -->
		<echo file="temp/version.properties">version=${DSTAMP}</echo>
		
		<!-- creates runtime jar -->
		<jar	jarfile="${stageName}/tahiti.runtime.jar"
				manifest="./MANIFEST.MF"
				compress="false">
			
			<fileset dir="temp"/>
			<!-- resource files -->
			<fileset dir="${stageName}/src">
				<include name="com/sun/tahiti/runtime/**/*.properties" />
			</fileset>
		</jar>
		
		<!-- purge the temp directory -->
		<delete dir="temp" />
		<mkdir  dir="temp" />
		
		
		<!-- compile tahiti comiler -->
		<javac	srcdir="${stageName}/src" destdir="temp">
			<classpath path="../package/msv.jar"/>
			<classpath path="../package/xsdlib.jar"/>
			
			<include name="**/*.java"/>
			<exclude name="com/sun/tahiti/runtime/**/*.java" />
		</javac>
		
		
		<!-- create a time stamp file -->
		<echo file="temp/version.properties">version=${DSTAMP}</echo>
		
		<!-- create compiler jar -->
		<jar	jarfile="${stageName}/tahiti.compiler.jar"
				manifest="./MANIFEST.MF"
				compress="false">
			
			<fileset dir="temp"/>
			<!-- resource files -->
			<fileset dir="${stageName}/src">
				<include name="**/*.properties" />
				<include name="**/*.xsl" />
			</fileset>
		</jar>
		<delete dir="temp" />
		
		
		<!-- copy jar file to package dir -->
		<copy file="${stageName}/tahiti.compiler.jar" todir="../package/" />
		<copy file="${stageName}/tahiti.runtime.jar" todir="../package/" />
		
		
		<!-- remove source codes -->
		<delete dir="${stageName}/src"/>
		
		<!-- copy relevant jars -->
		<copy todir="${stageName}" file="../package/msv.jar" />
		<copy todir="${stageName}" file="../package/xsdlib.jar" />
		<copy todir="${stageName}" file="${xalan.jar}" />
		<copy todir="${stageName}" file="${xerces.jar}" />
		<copy todir="${stageName}" file="${isorelax.jar}" />
		<copy todir="${stageName}" file="${relaxngDatatype.jar}" />
		
		<!-- creates distribution package -->
		<zip	zipfile="../package/tahiti.${DSTAMP}.zip"
				basedir="."
				includes="${stageName}/**/*.*" />
		
		<delete	dir="${stageName}" />
	</target>
</project>
