<project name="OKI" default="jar" basedir=".">

<!--
$Header: /cvs/oki/tech/contrib/mit/impl/build.xml,v 1.19 2002/10/15 21:08:30 giris Exp $

This ant build file:
		- builds from src into build/classes
    - makes a jar file from src/org/okip/*/*/impl
-->

<!--  ==================== 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="false" /> 

  <target name="init" >
    <property name="impl.name"   value="mitServiceImpl" />
    <property name="okilib.dir"   value="../../../build/lib" />
    <property name="build.dir"  value="${basedir}/build/classes" />
    <property name="buildlib.dir"  value="${basedir}/build/lib" />
    <property name="othersForImpl" value="krb4/**" />

    <property name="junit.jar"  value="${user.home}/lib/java/junit.jar" />
    <property name="servlet.jar" value="${user.home}/lib/java/servlet.jar" />

    <available property="servlet.present"
        classname="javax.servlet.http.HttpServletRequest" >
      <classpath>
        <pathelement location="${servlet.jar}" />
        <pathelement path="" />
        <pathelement path="${java.class.path}" />
      </classpath>
    </available>
    <available property="krb5.present"
        classname="javax.security.auth.Subject" >
      <classpath>
        <pathelement path="" />
        <pathelement path="${java.class.path}" />
      </classpath>
    </available>
    <available property="ssl.present"
        classname="javax.net.ssl.SSLSocket" >
      <classpath>
        <pathelement path="" />
        <pathelement path="${java.class.path}" />
      </classpath>
    </available>
    <tstamp />
  </target>

  <target name="JUNIT">
    <available property="junit.present" classname="junit.framework.TestCase" >
      <classpath>
        <pathelement location="${user.home}/lib/java/junit.jar" />
        <pathelement path="" />
        <pathelement path="${java.class.path}" />
      </classpath>
    </available>
  </target>

  <target name="compile" depends="JUNIT,init">
    <mkdir dir="${build.dir}"/>
    <javac srcdir="src" destdir="${build.dir}"
          debug="${compile.debug}"
          deprecation="${compile.deprecation}"
          optimize="${compile.optimize}" >
      <classpath>
        <pathelement location="${junit.jar}" />
        <pathelement location="${servlet.jar}" />
        <pathelement path="" />
        <pathelement path="${okilib.dir}/okiServiceApi.jar" />
        <pathelement path="${java.class.path}" />
      </classpath>
      <include name="**/*.java"/>
    <include name="**/edu/**/*.java"/>
    <exclude name="**/authenkrb5/*.java" unless="krb5.present" />
      <exclude name="**/x509/*.java" unless="servlet.present" />
      <exclude name="**/util/romi/**/*.java" unless="ssl.present" />
    </javac>

    <antcall target="rmictarget" />
    <antcall target="warnx509" />
    <antcall target="warnkrb5" />
    <antcall target="warnssl" />
    <copy todir="${build.dir}">
      <fileset dir="src">
        <include name="**/*.properties"/>
      </fileset>
    </copy>
  </target>
  
  <target name="rmictarget" if="ssl.present" depends="init">
        <rmic base="${build.dir}" classname="edu.mit.is.util.romi.server.Server" stubversion="1.2" verify="on"/>
  </target>

  <target name="warnx509" unless="servlet.present" >
    <echo message="Warning, not compiling x509: servlet jar not found" />
  </target>

  <target name="warnssl" unless="ssl.present" >
    <echo message="Warning, not compiling util/romi: ssl not found" />
  </target>

  <target name="warnkrb5" unless="krb5.present" >
    <echo message="Warning, not compiling authenkrb5: J2SE 1.4 or higher required" />
  </target>

  <target name="jar" depends="compile">
    <mkdir dir="${buildlib.dir}"/>
    <jar jarfile="${buildlib.dir}/${impl.name}.jar"
         basedir="${build.dir}" includes="**/impl/**,${othersForImpl},**/edu/**,classes" />
  </target>

  <target name="clean" depends="init">
    <delete dir="${build.dir}" />
    <delete dir="${buildlib.dir}" />
  </target>
</project>
