<?xml version="1.0"?>
<!-- 
        xjc-sub.xml: Generic ant build file for JAXB tasks
        Gary Gregory 
        07-March-2003.

        Properties to pass in:
	
        project.root.dir:               Where the calling build.xml file is located within the file system tree
        java.bind.pgk.slash:    The target package for java bindings with slashes in the name
        java.bind.pgk.dot:      The target package for java bindings with dots in the name
        xjc.schema:                     The schema file relative to the project root.
        xjc.binding:                    The binding file relative to the project root.
        xjc.use-runtime         Suppress the generation of the impl.runtime package and simply refer to another existing runtime in the specified package.

-->
<project basedir="." default="all">
    <!-- Start standard Seagull AIS JAXB properties -->
    <property name="java.dir" value="${project.root.dir}/Java"/>
    <property name="java.source.dir" value="${java.dir}/Source"/>
    <property name="cvs-store.root.dir" value="${project.root.dir}/../.."/>
    <property name="thirdparty.dir" value="${cvs-store.root.dir}/ThirdParty"/>
    <!-- End standard Seagull AIS JAXB properties -->
    <property name="jwsdp.dir" value="${thirdparty.dir}/sun/jwsdp/1.2"/>
    <path id="classpath">
        <fileset dir="${jwsdp.dir}/jaxb/lib" includes="*.jar" excludes="ant.jar"/>
        <fileset dir="${jwsdp.dir}">
            <include name="jaxp/**/*.jar"/>
            <include name="jwsdp-shared/lib/**/*.jar"/>
        </fileset>
    </path>
    <taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
        <classpath refid="classpath"/>
    </taskdef>
    <property name="cp" refid="classpath"/>
    <property name="java.bind.dir" value="${java.source.dir}/${java.bind.pgk.slash}"/>
    <target name="clean">
        <available file="${java.bind.dir}" type="dir" property="java.bind.dir.present"/>
        <antcall target="clean.java.bind.dir"/>
    </target>
    <!-- Use "if" target attribute to only-delete if present. -->
    <!-- We want to know if the files cannot be deleted, so we do not use the "quiet" attribute. -->
    <target name="clean.java.bind.dir" if="java.bind.dir.present">
        <delete>
            <!-- Do NOT delete any of the CVS directories! -->
            <fileset dir="${java.bind.dir}" includes="**/*.java **/*.properties **/*.ser "/>
        </delete>
    </target>
    <target name="xjc-binding-pkg" if="xjc.binding">
        <xjc schema="${project.root.dir}/${xjc.schema}" binding="${project.root.dir}/${xjc.binding}" target="${java.source.dir}" package="${java.bind.pgk.dot}">
            <arg value="-use-runtime"/>
            <arg value="com.seagullsw.toolbox.xml.jaxb.impl.runtime"/>
        </xjc>
    </target>
    <target name="xjc-binding" depends="info, clean">
        <xjc schema="${project.root.dir}/${xjc.schema}" binding="${project.root.dir}/${xjc.binding}" target="${java.source.dir}">
            <arg value="-use-runtime"/>
            <arg value="com.seagullsw.toolbox.xml.jaxb.impl.runtime"/>
        </xjc>
    </target>
    <target name="xjc-no-binding-pkg" unless="xjc.binding">
        <xjc schema="${project.root.dir}/${xjc.schema}" target="${java.source.dir}" package="${java.bind.pgk.dot}">
            <arg value="-use-runtime"/>
            <arg value="com.seagullsw.toolbox.xml.jaxb.impl.runtime"/>
        </xjc>
    </target>
    <target name="info">
        <echo message="Building with ${ant.version}"/>
        <echo message="Ant is using Java version ${ant.java.version}"/>
        <!--<echo message="The classpath is: ${cp}"/>-->
    </target>
    <target name="xjc-call" depends="xjc-binding-pkg, xjc-no-binding-pkg"/>
    <target name="xjc-runtime">
        <xjc schema="${project.root.dir}/${xjc.schema}" binding="${project.root.dir}/${xjc.binding}" target="${java.source.dir}" package="${java.bind.pgk.dot}">
        </xjc>
    </target>
    <target name="all" depends="info, clean, xjc-call"/>
</project>

