<project name="spring_java_1.0m3_castor_1.1" default="package">

	<path id="project.classpath">
		<pathelement location="build/classes"/>
		<fileset dir="lib" includes="*.jar"/>
    </path>

	<target name="clean">
		<delete dir="build"/>
	</target>
	
	<target name="init">
		<mkdir dir="build"/>
	</target>
	
	<target name="generate" depends="init">
		<mkdir dir="build/generated"/>
		<taskdef name="castor-srcgen" 
			classname="org.castor.anttask.CastorCodeGenTask"
		    classpathref="project.classpath" />
	    <castor-srcgen file="examples.xsd"
		    todir="build/generated" types="vector"
            package="org.w3c.dbwg.schema"
		    warnings="false" />
	</target>
	
	<target name="compile" depends="generate">
		<mkdir dir="build/classes"/>
		<javac classpathref="project.classpath" destdir="build/classes" debug="on">
			<src path="build/generated"/>
			<src path="src/java"/>
		</javac>
	</target>
	
	<target name="generate.castor.mapping" depends="init">
		<property file="mappingclasses.properties"/>
		<mkdir dir="build/tmp"/>
		<java classname="org.w3c.dbwg.util.castor.MappingTool" fork="yes">
			<arg value="build/tmp/mapping.xml"/>
			<arg value="${mappingclasses}"/>
			<classpath>
				<pathelement location="build/classes"/>
				<path refid="project.classpath"/>
			</classpath>
		</java>
		<replace file="build/tmp/mapping.xml" 
			token="&lt;class name=" 
			value="&lt;class verify-constructable=&quot;false&quot; name="/>
		<replace file="build/tmp/mapping.xml" 
			token="&lt;bind-xml name=&quot;" 
			value="&lt;bind-xml xmlns:foo=&quot;http://www.w3.org/2002/ws/databinding/examples/6/09/&quot; name=&quot;foo:"/>
	</target>
	
	<target name="package" depends="generate.castor.mapping">
		<property file="spring.properties"/>
		<mkdir dir="build/tmp/org/w3c/dbwg"/>
		<copy file="applicationContext-ws.xml.template" tofile="build/tmp/org/w3c/dbwg/applicationContext-ws.xml" overwrite="true">
			<filterset>
				<filter token="PROPS" value="${spring.mappings}"/>
			</filterset>
		</copy>
		<jar destfile="build/${ant.project.name}.jar">
			<fileset dir="build/classes"/>
			<fileset dir="build/generated" includes="**/*.cdr"/>
			<fileset dir="build/tmp" includes="**/*.xml"/>
		</jar>
		<war destfile="build/databinding.war" webxml="src/web/WEB-INF/web.xml">
			<webinf dir="src/web/WEB-INF"/>
			<lib dir="lib" excludes="jaxb-xjc*.jar"/>
			<lib dir="build" includes="${ant.project.name}.jar"/>
			<fileset dir="." includes="*.xsd,*.wsdl"/>
		</war>
	</target>

	<target name="deploy" depends="package">
		<copy file="build/databinding.war" todir="C:/jboss-4.0.5.GA/server/default/deploy" overwrite="true"/>
	</target>
	
</project>