<?xml version="1.0"?>

<!-- ====================================================================== 
     April 2005                                                    

     Vishnu build script
                   
     kjdon                                                                
     ====================================================================== -->
<project name="vishnu" default="all" basedir=".">

  <property environment="env"/>
  <property name="build.dir" value="${basedir}/build"/>
  <property name="src.dir" value="${basedir}/src"/>

  <!-- if vishnu is installed as a package inside greenstone -->
  <property name="prefix" value="../.."/>
  <!-- use if vishnu is standalone -->
  <property name="prefix" value="${basedir}"/>
  <property name="catalina.home" value="${env.CATALINA_HOME}"/>
  <property name="web.lib" value="${prefix}/web/WEB-INF/lib"/>
  <property name="web.classes" value="${prefix}/web/WEB-INF/classes"/>


<!--  ==================== Compilation Control Options ==================== -->

<!--

  These properties control option settings on the Javac compiler when it
  is invoked using the <javac> task.

  compile.debug        Should compilation include the debug option?

  compile.deprecation  Should compilation include the deprecation option?

  compile.optimize     Should compilation include the optimize option?

-->

  <property name="compile.debug"       value="true"/>
  <property name="compile.deprecation" value="true"/>
  <property name="compile.optimize"    value="true"/>

  <!-- classpath : this is for vishnu with Greenstone. For standalone vishnu,
  make sure all the specified jar files are on the environment CLASSPATH -->
  <path id="compile.classpath">
    <pathelement location="${prefix}/lib/jni/mg.jar"/>
    <pathelement location="${web.lib}/lucene-1.4.1.jar"/>
    <pathelement location="${catalina.home}/common/lib/servlet-api.jar"/>
    <pathelement location="${catalina.home}/common/endorsed/xercesImpl.jar"/>
    <pathelement path="${env.CLASSPATH}"/>
    <!-- if not usign this with greenstone, don't need this -->
    <pathelement location="${web.lib}/gsdl3.jar"/>
  </path>

  <path id="ld.library.path">
    <pathelement location="${prefix}/lib/jni"/>
  </path>
  <target name="all" depends="clean,compile"/>

  <target name="clean" depends=""
    description="Remove the compiled code">
    <delete dir="${build.dir}"/>
  </target>
  
  <target name="compile" depends=""
    description="Compile the code">
    <mkdir dir="${build.dir}"/>
    <javac srcdir="${src.dir}"
      destdir="${build.dir}"
      debug="${compile.debug}"
      deprecation="${compile.deprecation}"
      optimize="${compile.optimize}">
      <classpath>
	<path refid="compile.classpath"/>
      </classpath>
      <!-- uncomment this if not in a greenstone context -->
      <!--<exclude name="org/**"/>-->
    </javac>
    <jar destfile="${build.dir}/vishnu.jar">
      <fileset dir="${build.dir}">
	<include name="vishnu/**"/>
	<include name="org/**"/>
      </fileset>
      <manifest>
	<attribute name="Built-By" value="${user.name}" />
      </manifest>
    </jar>      
    <copy file="${build.dir}/vishnu.jar" todir="${web.lib}"/>
  </target>
</project>