<?xml version="1.0"?>
<project name="spring-oxm-maven2-targets" default="generate-test-sources">
    <condition property="skip">
        <equals arg1="${maven.test.skip}" arg2="true"/>
    </condition>

    <property name="schema" value="${basedir}/src/test/resources/org/springframework/oxm/flight.xsd"/>
    <property name="generate.target.directory" value="${basedir}/target/generated-sources/test/java"/>

    <target name="generate-test-sources" depends="generate-test-jaxb,generate-test-xmlbeans,generate-test-castor">
        <copy todir="${basedir}/target/test-classes">
            <fileset dir="${generate.target.directory}">
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>

    <target name="generate-test-init">
        <mkdir dir="${generate.target.directory}"/>
    </target>

    <target name="generate-test-jaxb" depends="generate-test-init" unless="skip">
        <taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask" classpathref="maven.test.classpath"/>
        <xjc target="${generate.target.directory}" package="org.springframework.oxm.jaxb1" schema="${schema}">
            <produces dir="${generate.target.directory}" includes="**/jaxb1/**/*.java"/>
        </xjc>
    </target>

    <target name="generate-test-xmlbeans" unless="skip">
        <taskdef name="xmlbean" classname="org.apache.xmlbeans.impl.tool.XMLBean" classpathref="maven.test.classpath"/>
        <xmlbean schema="${schema}" classgendir="${basedir}/target/test-classes" classpathref="maven.test.classpath"/>
    </target>

    <target name="generate-test-castor" depends="generate-test-init" unless="skip">
        <taskdef name="castor-srcgen" classname="org.castor.anttask.CastorCodeGenTask"
                 classpathref="maven.test.classpath"/>
        <castor-srcgen types="j2" warnings="false" file="${schema}" todir="${generate.target.directory}"
                       package="org.springframework.oxm.castor"/>
    </target>

    <target name="test-compile" depends="test-compile-jibx"/>

    <target name="test-compile-jibx" unless="skip">
        <taskdef name="jibx-bind" classname="org.jibx.binding.ant.CompileTask" classpathref="maven.test.classpath"/>
        <jibx-bind load="true" binding="${basedir}/src/test/resources/org/springframework/oxm/jibx/binding.xml">
            <classpathset dir="${basedir}/target/test-classes">
                <include name="**/jibx/**/*"/>
            </classpathset>
        </jibx-bind>
    </target>


</project>