<?xml version="1.0"?>
<project name="pharos" basedir="." default="help">

  <!-- ??? whats the best way to get this???-->
  <property name="gsdl3srchome" value="../.."/>
  <property name="gsdl3home" value="../../web"/>

  <!-- ============ classpath =================== -->
 <path id="project.classpath">
    <fileset dir="${gsdl3srchome}/lib/java">
      <include name="**/*.jar"/>
    </fileset>
  </path>

  <!-- ============ self defined tasks =================== -->  
<taskdef name="if" classname="ise.antelope.tasks.IfTask" classpathref="project.classpath"/>
  <!-- create build.properties if it has not been created yet -->
<!--  <if>
    <bool><not><available file="build.properties"/></not></bool>
    <copy file="build.properties.in" tofile="build.properties"/>
  </if>-->
  <!-- now use the properties -->
  <property file="build.properties"/>
  <!-- get top level properties - or will we be running this from top level??-->
  <property file="${gsdl3srchome}/build.properties"/>

  <!-- get properties from the environment -->
  <property environment="env"/>
  <property name="gsdlhome" value="${env.GSDL3SRCHOME}/gs2build"/>
  <property name="tomcat.home" value="${gsdl3srchome}/packages/tomcat"/>
  <property name="web.home" value="${basedir}/web"/>
  <property name="derbydb.home" value="${basedir}/web/derbyDB"/>
  <property name="webservices.home" value="${basedir}/web/WEB-INF/services"/>
  <property name="webclasses.home" value="${basedir}/web/WEB-INF/classes"/>

  <target name="help" description="print a help message">
    <echo message="  Execute 'ant -projecthelp' for a list of targets."/>
    <echo message="  Execute 'ant -help' for Ant help."/>
  </target>
  <target name="configure" description="set up all the properties files etc">
    <!-- set up the pharos tomcat context -->
    <copy file="${basedir}/resources/tomcat/pharos.xml" tofile="${tomcat.home}/conf/Catalina/localhost/pharos.xml" overwrite="true">
      <filterset>
        <filter token="pharoswebhome" value="${web.home}"/>
      </filterset>
    </copy>

    <!-- generate VSprops.properties from .in file-->
    <copy file="${basedir}/resources/java/VSprops.properties.in" tofile="${basedir}/classes/VSprops.properties" overwrite="true">
      <filterset>
	<filter token="pharosishome" value="${basedir}"/>
	<filter token="gsdlhome" value="${gsdlhome}"/>
	<filter token="pharosos" value="${env.GSDLOS}"/>
	<filter token="tomcat.server" value="${tomcat.server}"/>
	<filter token="tomcat.port" value="${tomcat.port}"/>
      </filterset>
    </copy>

    <!-- generate CBSE.properties from .in file-->
    <copy file="${webservices.home}/CBSE.properties.in" tofile="${webservices.home}/CBSE.properties" overwrite="true">
      <filterset>
	<filter token="tomcat.server" value="${tomcat.server}"/>
	<filter token="tomcat.port" value="${tomcat.port}"/>
      </filterset>
    </copy>

    <!-- generate log4j.properties from .in file-->
    <copy file="${webclasses.home}/log4j.properties.in" tofile="${webclasses.home}/log4j.properties" overwrite="true">
      <filterset>
	<filter token="tomcathome" value="${tomcat.home}"/>
      </filterset>
    </copy>


    <!-- generate empty DB if one does not already exist -->

    <copy todir="${derbydb.home}/gsImageSearchDB" overwrite="false">
      <fileset dir="${derbydb.home}/gsImageSearchDB.empty"/>
    </copy>

    <mkdir dir="/tmp/vstmpdir"/>
    <mkdir dir="/tmp/vsupload"/>
  </target>

  <target name="display">
    <echo>gsdl3home ${gsdl3srchome}</echo>
    <echo> tomcat port: ${tomcat.port}</echo>
    <echo> tomcat url: ${tomcat.server}</echo>
  </target>

  <path id="compile.classpath">
    <pathelement location="${basedir}/pharos-imageis-lib.jar"/>
    <!-- Include all jar files in the lib directory -->
    <fileset dir="${basedir}/lib">
      <include name="*.jar"/>
    </fileset>
    <!-- Include all jar files in gsdl3 web/lib -->
<!--    <pathelement location="${gsdl3srchome}/web/lib"/>-->
    <fileset dir="${gsdl3home}/WEB-INF/lib">
      <include name="*.jar"/>
    </fileset>
    <!--<pathelement location="{gsdl3srchome}/build/gsdl3.jar"/>-->
  </path>
  
  <target name="compile" description="Compile up the PharosImageIS classes">
    <javac srcdir="${basedir}/src/java"
      destdir="${basedir}/classes"
      debug="${compile.debug}"
      deprecation="${compile.deprecation}"
      optimize="${compile.optimize}">
      <classpath>
        <path refid="compile.classpath"/>
      </classpath>
    </javac>
    <jar destfile="pharos-imageis.jar">
      <fileset dir="${basedir}/classes">
        <include name="imageis/**"/>
      </fileset>
      <manifest>
        <attribute name="Class-Path" value="./ lib/commons-io-1.4.jar lib/activation-1.1.jar lib/annogen-0.1.0.jar lib/axiom-api-1.2.7.jar lib/axiom-dom-1.2.7.jar lib/axiom-impl-1.2.7.jar lib/axis2-adb-1.4.1.jar lib/axis2-adb-codegen-1.4.1.jar lib/axis2-ant-plugin-1.4.1.jar lib/axis2-clustering-1.4.1.jar lib/axis2-codegen-1.4.1.jar lib/axis2-corba-1.4.1.jar lib/axis2-fastinfoset-1.4.1.jar lib/axis2-java2wsdl-1.4.1.jar lib/axis2-jaxbri-1.4.1.jar lib/axis2-jaxws-1.4.1.jar lib/axis2-jaxws-api-1.4.1.jar lib/axis2-jibx-1.4.1.jar lib/axis2-json-1.4.1.jar lib/axis2-jws-api-1.4.1.jar lib/axis2-kernel-1.4.1.jar lib/axis2-metadata-1.4.1.jar lib/axis2-mtompolicy-1.4.1.jar lib/axis2-saaj-1.4.1.jar lib/axis2-saaj-api-1.4.1.jar lib/axis2-spring-1.4.1.jar lib/axis2-xmlbeans-1.4.1.jar lib/backport-util-concurrent-3.1.jar lib/commons-codec-1.3.jar lib/commons-fileupload-1.2.jar lib/commons-httpclient-3.1.jar lib/commons-io-1.4.jar lib/commons-logging-1.1.1.jar lib/geronimo-annotation_1.0_spec-1.1.jarlib/geronimo-stax-api_1.0_spec-1.0.1.jar lib/httpcore-4.0-beta1.jar lib/httpcore-nio-4.0-beta1.jar lib/jalopy-1.5rc3.jar lib/jaxb-api-2.1.jar lib/jaxb-impl-2.1.6.jar lib/jaxb-xjc-2.1.6.jar lib/jaxen-1.1.1.jar lib/jettison-1.0-RC2.jar lib/jibx-bind-1.1.5.jar lib/jibx-run-1.1.5.jar lib/log4j-1.2.15.jar lib/mail-1.4.jar lib/mex-1.4.1.jar lib/neethi-2.0.4.jar lib/soapmonitor-1.4.1.jar lib/woden-api-1.0M8.jar lib/woden-impl-dom-1.0M8.jar lib/wsdl4j-1.6.2.jar lib/wstx-asl-3.2.4.jar lib/xalan-2.7.0.jar lib/xercesImpl-2.8.1.jar lib/xml-apis-1.3.04.jar lib/xml-resolver-1.2.jar lib/xmlbeans-2.3.0.jar lib/XmlSchema-1.4.2.jar lib/Ftf2Mpeg7.jar lib/M7v2schema.jar lib/xbean.jar lib/xbean_xpath.jar lib/xmlbeans-qname.jar lib/xmltypes.jar lib/ShotMpeg7.jar lib/pharos-imageis-lib.jar"/>
	<attribute name="Main-Class" value="imageis.ImageIS"/>
      </manifest>
    </jar>

  </target>

  <target name="install" description="copy all the necessary files into gs3 web area">
    <copy todir="${gsdl3home}/WEB-INF/classes">
      <fileset dir="${basedir}/classes"/>
    </copy>
    <copy file="${basedir}/pharos-imageis.jar" todir="${gsdl3home}/WEB-INF/lib"/>
    <copy file="${basedir}/lib/pharos-imageis-lib.jar" todir="${gsdl3home}/WEB-INF/lib"/>
  </target>
</project>



