<?xml version="1.0"?>

<!-- ======================================================================= -->
<!-- eXist embedded into Jboss build file                                    -->
<!--                                                                         -->
<!--                                                                         -->
<!-- ======================================================================= -->

<project name="JBoss-XMLDB" default="jar" basedir=".">


    <property name="build" value="./classes"/>
    <property name="src" value="./src"/>
    <property name="samples" value="./samples"/>
    <property name="lib" value="./lib"/>
    <property name="server.root" value="../.."/>
    <property name="server.lib" value="${server.root}/lib"/>
    <property file="${server.root}/build.properties"/>
    <property name="conf" value="./conf"/>
    <property name="dist" value="./dist"/>
    <property name="dist.dir" value="${dist}/${ant.project.name}-${build.version}"/>

    <path id="cp">
        <fileset dir="${basedir}/lib">
            <include name="*.jar"/>
        </fileset>
        <fileset dir="${server.lib}">
			<include name="core/*.jar"/>
        </fileset>
        <fileset dir="${server.root}">
            <include name="*.jar"/>
        </fileset>
        <pathelement path="${build}/classes"/>
        <pathelement path="${java.class.path}"/>
    </path>
    <!--======================================================================
         Calls the build.xml script so that we get all common stuff done
         first
    =======================================================================-->
    <target name="prepare">
        <mkdir dir="${dist.dir}" />
        <mkdir dir="${build}" />
    </target>

    <!--======================================================================
         Compile all sources
    =======================================================================-->
    <target name="compile" depends="prepare">
        <javac srcdir="${src}"
               destDir="${build}"
               classpathref="cp"
               failonerror="true"
               deprecation="on"/>
    </target>

    <!--======================================================================
          Package XMLDB service
    =======================================================================-->
    <target name="package.exist.service" depends="compile">
        <jar jarfile="${dist.dir}/eXist.sar">
            <zipfileset dir="${conf}/eXist" includes="jboss-service.xml" prefix="META-INF"/>
            <fileset dir="${build}" includes="org/exist/jboss/**" />

            <zipfileset dir="${server.lib}/core"
                      includes="antlr-*.jar,
                                commons-pool-*.jar,
                                resolver.jar,
                                xmlrpc-*.jar,
                                xmldb.jar" />
            <zipfileset dir="${server.root}"
                      includes="exist.jar,
					  			exist-optional.jar" />
        </jar>
    </target>

    <!--======================================================================
          Package XMLDB service samples
    =======================================================================-->
    <target name="package.xmldb.service.samples" depends="compile">
        <jar jarfile="${dist.dir}/xmldbsamples.sar">
            <zipfileset dir="${conf}/samples" includes="*.xml" prefix="META-INF"/>
            <fileset dir="${build}" includes="samples/**" />
        </jar>
    </target>

    <target name="jar" depends="package.exist.service, package.xmldb.service.samples">
    </target>
</project>
