<project name="Castor XML - CTF" default="compile.xmlctf" basedir=".">

    <!-- $Id: build.xml 0000 2007-01-19 21:12:08Z ekuns $ -->

    <property environment="env" />
    <property name="source"               value="${basedir}/src"/>
    <property name="main.java"            value="${source}/main/java"/>
    <property name="main.resources"       value="${source}/main/resources"/>
    <property name="main.generated"       value="${basedir}/target/generated-sources/castor" />
    <property name="test.resources"       value="${source}/test/resources"/>
    <property name="build"                value="${basedir}/build"/>
    <property name="classes"              value="${build}/classes"/>
    <property name="archive"              value="${project}-${version}${release}-xmlctf-framework"/>
    <property name="gen.src"              value="${build}/generated-sources"/>

    <path id="build.classpath">
        <pathelement location="${basedir}/build/classes"/>
        <pathelement location="${basedir}/../build/classes"/>
        <pathelement location="${basedir}/../CORE/build/classes"/>
        <pathelement location="${basedir}/../schema/build/classes"/>
        <pathelement location="${basedir}/../codegen/build/classes"/>
        <pathelement location="${basedir}/../anttask/build/classes"/>
        <pathelement location="${basedir}/../diff/build/classes"/>
        <pathelement location="${basedir}/../lib/commons-logging-1.1.jar"/>
        <pathelement location="${basedir}/../lib/junit_3.8.2.jar"/>
    </path>

    <target name="prepare.xmlctf" unless="prepare.xmlctf.executed">
        <mkdir dir="${build}"/>
        <mkdir dir="${classes}"/>
        <property name="prepare.xmlctf.executed" value="true"/>
    </target>

    <target name="clean.xmlctf" description="Removes XML CTF build directory">
        <delete dir="${build}"/>
    </target>

	<target name="compile.xmlctf" depends="prepare.xmlctf" description="Compile XML CTF">
        <javac srcdir="${main.generated}" destdir="${classes}" 
               debug="on" encoding="ISO-8859-1" deprecation="false"
               source="1.5" target="1.5">
            <classpath refid="build.classpath"/>
        </javac>
        <javac srcdir="${main.java}" destdir="${classes}"
               debug="on" encoding="ISO-8859-1" deprecation="false"
        	   source="1.5" target="1.5">
            <classpath refid="build.classpath"/>
        </javac>
        <copy todir="${classes}">
            <fileset dir="${main.generated}">
                <include name="**/*.cdr"/>
            </fileset>
            <fileset dir="${main.resources}">
                <include name="**"/>
            </fileset>
            <filterset begintoken="$${" endtoken="}">
                <filter token="VERSION" value="${version}"/>
                <filter token="RELEASE" value="${release}"/>
            </filterset>
        </copy>
        <copy todir="${classes}">
            <fileset dir="${test.resources}">
                <include name="log4j.xml"/>
            </fileset>
        </copy>
    </target>

    <target name="jar.xmlctf" depends="compile.xmlctf" description="Build XML CTF JAR file">
        <jar jarfile="${build}/${archive}.jar" basedir="${classes}" includes="**"
             manifest="${classes}/META-INF/MANIFEST.MF"/>
        <copy file="${build}/${archive}.jar" tofile="${basedir}/../dist/${archive}.jar"/>
    </target>

    <target name="gen.testdescriptor" depends="compile.xmlctf"
            description="Use the Source Generator to create the Java classes for TestDescriptor.xsd">
        <delete dir="${gen.src}/testdescriptor"/>
        <mkdir dir="${gen.src}/testdescriptor"/>
        <taskdef name="castor-srcgen" classname="org.castor.anttask.CastorCodeGenTask"
                 classpathref="build.classpath"/>
        <castor-srcgen file="${main.resources}/org/exolab/castor/tests/framework/TestDescriptor.xsd"
                       todir="${gen.src}/testdescriptor"
                       package="org.exolab.castor.tests.framework.testDescriptor"
                       lineseparator="unix"
                       warnings="true"/>
        <javac destdir="${classes}" excludes="${excludes}"
               debug="${main.opt.debug}" encoding="ISO-8859-1" deprecation="off"
               optimize="on" source="1.5" target="1.5">
            <src path="${gen.src}" />
            <classpath refid="build.classpath"/>
        </javac>
    </target>

</project>
