<?xml version="1.0"?>
<!--
	Ant build script for XSDLib.
	
	$Id: build.xml 1723 2006-08-14 17:24:38Z kohsuke $
	
	
	
	Tasks to help development
	=========================
	javacc
		run JavaCC
	binary
		compile everything to the bin directory.
	javadoc
		run javadoc on the working copy. Useful to check the documentation
		without actually creating a distribution package.
	test
		test core msv codes. parser, verifier and several related codes.
	release
		create a distribution package
	
-->
<project name="rngconverter" 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" />
			<classpath path="${xerces.jar}:${junit.jar}:${relaxngDatatype.jar}:${resolver.jar}"/>
		</javac>
	</target>
	
	
	
	
	
	
	
	
	
	<!-- test the working directory -->
	<target name="test">
		<ant antfile="../shared/ant.test.xml" target="test" />
	</target>
	
	
	<!-- test the distribution package -->
	<target name="test_release">
		<ant antfile="../shared/ant.test.xml" target="test_release">
			<property name="testJar" value="../package/rngconv.jar"/>
		</ant>
	</target>
	
	
	
	
	<!-- RELAX NG converter release -->
	<target name="dist" description="build the distribution package into the dist/ dir">
		<tstamp>
      <format property="YEAR" pattern="yyyy" locale="en"/>
    </tstamp>
		
		<delete	dir="dist" />
		<mkdir	dir="dist/src" />
		
		<!-- copy files -->
		<copy todir="dist/src">
			<fileset dir="src" />
		</copy>
				
		<!-- obtain document files -->
		<copy todir="dist">
			<fileset dir="doc"/>
		</copy>
		
    <replace dir="dist">
        <include name="**/*.html"/>
        <include name="**/*.txt"/>
        <replacefilter token="@@VERSION@@" value="${DSTAMP}" />
        <replacefilter token="@@YEAR@@" value="${YEAR}" />
    </replace>
		
		
		<!-- compile files -->
		<mkdir	dir="temp" />
		<javac	srcdir="dist/src" destdir="temp">
			
			<classpath path="../package/msv.jar"/>
			<classpath path="../package/xsdlib.jar"/>
			
			<include name="**/*.java" />
		</javac>
		
		<!-- create a time stamp file -->
		<echo file="temp/version.properties">version=${DSTAMP}</echo>
		
		<!-- creates the complete binary jar -->
		<jar	jarfile="dist/rngconv.jar"
				manifest="./MANIFEST.MF"
				compress="${compress}">
			<fileset dir="dist/src" includes="**/*.properties" />
			<fileset dir="temp" includes="**/*.*" />
		</jar>
		<delete dir="temp" />
		
		<!-- copy jar file to package dir -->
		<copy file="dist/rngconv.jar" tofile="../package/rngconv.jar" />
		
		<!-- we don't create javadoc for rngconv -->

<!-- temporarily, remove source codes -->
		<delete dir="dist/src" />
		
		<!-- copy additional jars -->
		<copy file="../package/xsdlib.jar" tofile="dist/xsdlib.jar" />
		<copy file="../package/msv.jar" tofile="dist/msv.jar" />
		<copy file="${relaxngDatatype.jar}" tofile="dist/relaxngDatatype.jar" />
		<copy file="${isorelax.jar}" tofile="dist/isorelax.jar" />
		<copy file="${xerces.jar}" tofile="dist/xerces.jar" />
	</target>
	
	
	
	
	
	<target name="release" depends="dist" description="build the distribution zip file">
    <tstamp />
		<property name="stageName" value="rngconv-${DSTAMP}"/>
		
		<!-- copy jar file to package dir -->
		<copy file="dist/rngconv.jar" tofile="../package/rngconv.jar" />
		
		<!-- creates distribution package -->
		<mkdir dir="../package"/>
		<zip	zipfile="../package/rngconv.${DSTAMP}.zip">
			<zipfileset dir="dist" includes="**/*.*" prefix="${stageName}" />
		</zip>
	</target>
	
	<target name="clean">
		<delete dir="bin" />
		<delete dir="dist" />
		<delete dir="temp" />
	</target>
</project>
