<?xml version="1.0"?>
<project name="schmit" 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}:${relaxngDatatype.jar}:${isorelax.jar}:${junit.jar}"/>
		</javac>
	</target>
	
	
	
	
	
	
	
	<path id="release.classpath">
		<pathelement path="../package/msv.jar"/>
		<pathelement path="../package/xsdlib.jar"/>
		<pathelement path="${java.class.path}"/>
		<pathelement path="${xerces.jar}"/>
		<pathelement path="${relaxngDatatype.jar}"/>
		<pathelement path="${isorelax.jar}"/>
	</path>
	
	
	<!-- generator 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 source code -->
		<copy todir="dist/src">
			<fileset dir="src" />
		</copy>
		
		<!-- copy 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 refid="release.classpath"/>
			<include name="**/*.java" />
		</javac>
		
		<!-- create a time stamp file -->
		<echo file="temp/version.properties">version=${DSTAMP}</echo>
		
		<!-- creates the binary jar -->
		<jar	jarfile="dist/schmit.jar"
				manifest="./MANIFEST.MF"
				compress="${compress}">
			<fileset dir="dist/src" includes="**/*.properties" />
			<fileset dir="temp" includes="**/*.*" />
		</jar>
		<delete dir="temp" />
		
		
		<!-- creates javadoc -->
		<mkdir		dir="dist/javadoc" />
		<javadoc	locale="en_US"
					packagenames="com.sun.msv.schmit.*"
					sourcepath="dist/src"
					destdir="dist/javadoc"
					windowtitle="Schmit: Schema-in-transformation XSLT add-on"
					public="yes"
					author="yes"
					>
			
			<classpath refid="release.classpath"/>
			
			<link offline="true" href="http://java.sun.com/products/jdk/1.2/docs/api"
				packagelistLoc="../shared/ExternalPackageLists/CoreAPI" />
			<link offline="true" href="http://xml.apache.org/apiDocs/"
				packagelistLoc="../shared/ExternalPackageLists/XML" />
			<link offline="true" href="http://relaxng.sourceforge.net/datatype/java/apiDocs/"
				packagelistLoc="../shared/ExternalPackageLists/RELAXNG" />
			<link offline="true" href="http://xml.apache.org/xalan-j/apidocs/"
				packagelistLoc="../shared/ExternalPackageLists/Xalan" />
		</javadoc>
		
		
<!-- 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>
	
	
	
	
  <!-- generate release -->
  <target name="release" depends="dist" description="build the distribution zip file">
  	<tstamp />
		<property name="stageName" value="schmit-${DSTAMP}"/>
		
		<!-- copy jar file to package dir -->
		<copy file="dist/schmit.jar" tofile="../package/schmit.jar" />
		
		<!-- creates distribution package -->
    <zip  zipfile="../package/schmit.${DSTAMP}.zip">
    	<zipfileset dir="dist" prefix="${stageName}" />
    </zip>
	</target>
	
</project>
