<?xml version="1.0" encoding="UTF-8"?>
<project name="GoogleAddressBeans" default="build">
	<property name="lib.dir" location="${basedir}/lib"/>
	<property name="src.dir" location="${basedir}/src"/>
	<property name="bin.dir" location="${basedir}/bin"/>
	<!-- build the jars -->
	<target name="build_jar">
		<mkdir dir="${basedir}/jars"/>
		<jar destfile="${basedir}/jars/${ant.project.name}.jar" basedir="${basedir}/bin/"/>
		<jar destfile="${basedir}/jars/${ant.project.name}_src.jar" basedir="${basedir}/src/"/>
	</target>
	<!-- the main target that builds everything -->
	<target name="build">
		<delete dir="${src.dir}"/>
		<delete dir="${bin.dir}"/>
		<antcall target="generate_source"/>
		<antcall target="compile"/>
		<antcall target="build_jar"/>
		<delete dir="${src.dir}"/>
		<delete dir="${bin.dir}"/>
	</target>
	<!-- setup the classpath -->
	<path id="gen-classpath">
		<fileset dir="${lib.dir}">
			<include name="*.jar"/>
		</fileset>
	</path>
	<path id="compile-classpath">
		<fileset dir="${lib.dir}">
			<include name="*.jar"/>
		</fileset>
	</path>
	<!-- declare the SourceGenerator Taskdef -->
	<taskdef name="generator" classname="com.xmltravel.taskdefs.CastorSourceGenerator">
		<classpath refid="gen-classpath"/>
	</taskdef>
	<!-- compile the generated source -->
	<target name="compile">
		<mkdir dir="${bin.dir}"/>
		<javac srcdir="${src.dir}" destdir="${bin.dir}">
			<classpath refid="compile-classpath"/>
		</javac>
	</target>
	<!-- Generate source from schemata -->
	<target name="generate_source">
		<delete dir="${src.dir}"/>
		<mkdir dir="${src.dir}"/>
		<generator javaclassmapping="type">
			<classpath refid="gen-classpath"/>
			<schemaInstance filename="${basedir}/kml.xsd" java_package="my.beans.googleaddress" output_dir="${src.dir}"/>
		</generator>
	</target>
</project>

