<?xml version="1.0" encoding="UTF-8"?>
<!--
    Ant buildfile to load the PDF test documents from the TET distribution
    into an Oracle database.
    
    The following properties must be specified on the command line, or in
    an Ant "build.properties" file:
    
    tet.jdbc.connection         The JDBC connection URL, e.g.
                                "jdbc:oracle:thin:@localhost:1521:oracle".
                                
    tet.jdbc.user               The user name for connecting to the database.
    
    tet.jdbc.password           The password for connecting to the database.
    
    The JAR file for the Oracle JDBC driver is expected in the same directory
    as this build.xml file. If the JAR file is not located in the build
    directory, provide that pathname of the JAR file with the following
    property:
    
    oracle.jdbc.jar             Full path to the JAR file of the Oracle
                                JDBC driver.
                                
    The build file is prepared for being run directly from the TET installation
    directory. The TET JAR file, the corresponding TET JNI library and the
    directory containing the TET PDF test files are all expected relative to
    the current directory. If the build is performed elsewhere, specify the
    necessary pathnames with the following properties:
    
    tet.data.dir                Path to "bind/data" directory in the
                                TET installation directory, for example
                                "/home/user/TET-3.0dev1-Linux/bind/data", or
                                "C:\Program Files\PDFlib\TET 4.0 32-bit\bind\data".

    tet.jar                     Path to TET JAR file.
    
    tet.jni.dir                 Directory containing the TET JNI library.
    
    A sample Ant call could look like:
    
    ant -Dtet.jdbc.connection=jdbc:oracle:thin:@localhost:1521:orcl \
        -Dtet.jdbc.user=HR -Dtet.jdbc.password=HR
-->
<project name="TET PDF Loader" basedir="." default="load-database">
    <property file="build.properties"/>

    <!-- Location of the TET PDF test documents -->
    <property name="tet.data.dir" value="../../bind/data"/>
    
    <!-- Location of the TET Java binaries. -->
    <property name="tet.java.dir" value="../../bind/java"/>
    <property name="tet.jni.dir" value="${tet.java.dir}"/>
    <property name="tet.jar" value="${tet.java.dir}/TET.jar"/>

    <!-- Oracle JDBC driver JAR -->
    <property name="oracle.jdbc.jar" value="ojdbc14.jar"/>
    
    <path id="classpath">
        <pathelement location="${oracle.jdbc.jar}"/>
        <pathelement location="${tet.jar}"/>
        <pathelement location="."/>
    </path>
    
    <target name="load-database" depends="compile">
        <fail message="Path to the 'bind/data' directory in the TET installation directory must be specified in property 'tet.data.dir'"
            unless="tet.data.dir"/>
        <fail message="JDBC connection URL must be specified via must be specified in property 'tet.jdbc.connection'"
            unless="tet.jdbc.connection"/>
        <fail message="User name for database connection must be specified in property 'tet.jdbc.user'"
            unless="tet.jdbc.user"/>
        <fail message="Password for database connection  must be specified in property 'tet.jdbc.password'"
            unless="tet.jdbc.password"/>
        <java classname="tet_pdf_loader" fork="true">
            <classpath refid="classpath"/>
            <jvmarg value="-Djava.library.path=${tet.jni.dir}"/>
            <jvmarg value="-Dtet.data.dir=${tet.data.dir}"/>
            <jvmarg value="-Dtet.jdbc.connection=${tet.jdbc.connection}"/>
            <jvmarg value="-Dtet.jdbc.user=${tet.jdbc.user}"/>
            <jvmarg value="-Dtet.jdbc.password=${tet.jdbc.password}"/>
        </java>
    </target>
    
    <target name="compile">
        <javac srcdir=".">
            <classpath refid="classpath"/>
            <include name="tet_pdf_loader.java"/>
        </javac>
    </target>
    
    <target name="clean">
        <delete file="tet_pdf_loader.class"/>
    </target>
</project>
