
<project name="DirectorySearchApp" default="codegen" basedir=".">

<!-- ==================== File and Directory Names ======================== -->

<!--

  These properties generally define file and directory names (or paths) that
  affect where the build process stores its outputs.
-->

  <property name="app.name"   value="okiAPI"/>
  <property name="api.name"   value="okiSID"/>
  <property name="impl.name"  value="okiSIDimpl"/>
  <property name="tests.name" value="okiServiceApiTest"/>

  <property name="gen.dir"     value="${basedir}/."/>
  <property name="top.dir"     value=".\..\.."/>
  <property name="build.home"  value="${top.dir}\build"/>
  <property name="build.dir"   value="${build.home}\classes"/>
  <property name="buildlib.dir" value="${build.home}\lib"/>
  <property name="extlib.home"    value="${top.dir}/extlib"/>
  <property name="lib.dir"    value="${top.dir}\lib"/>
  <property name="dist.home"   value="${top.dir}/eas/dist"/>
  <property name="dist.src"   value="${dist.home}/src"/>
  <property name="junit.jar"   value="${user.home}/lib/java/junit.jar"/>
  <property name="rootpkg.dir" value="eas"/>

<!-- ==================== Compilation Classpath =========================== -->
<!--

  Rather than relying on the CLASSPATH environment variable, Ant includes
  features that makes it easy to dynamically construct the classpath you
  need for each compilation.

-->

  <path id="compile.classpath">
    <pathelement path="${java.class.path}"/>
    <pathelement location="${junit.jar}"/>
    <pathelement path=""/>
  </path>


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


<!-- ==================== Clean Target ==================================== -->
<!--
  The "clean" target deletes any previous "build" and "dist" directory,
  so that you can be ensured the application can be built from scratch.

-->

  <target name="clean" depends="init">
    <echo message="java classpath = ${java.class.path}"/>
    <delete__ dir="${build.home}"/>
    <delete__ dir="${dist.home}"/>
  </target>



<!-- ==================== Init Target ====================================== -->
<!--

  The "init" (or "prepare") target is used to create the "build" destination directory 
  and verify conditions for other tasks are met.   If you need
  to copy static files from external dependencies, you can customize the
  contents of this task.

  Normally, this task is executed indirectly when needed.

-->

  <target name="init">
    <condition property="libs.present">
      <and>
        <available file="${lib.dir}/okiSID.jar"/>
        <available file="${lib.dir}/okiSIDimpl.jar"/>
      </and>
    </condition>

    <condition property="java1.4.present">
      <equals arg1="${ant.java.version}" arg2="1.4"/>
    </condition>

    <condition property="ant.exec" value="ant.bat">
      <os family="windows"/>
    </condition>

    <condition property="ant.exec" value="ant">
      <not>
        <os family="windows"/>
      </not>
    </condition>

    <tstamp/>

    <path id="project.class.path">
      <pathelement location="${lib.dir}/okiServiceApi.jar"/>
      <pathelement location="${lib.dir}/okiServiceImpl.jar"/>
      <pathelement location="${lib.dir}/mitServiceImpl.jar"/>
      <pathelement path="build"/>
    </path>

  </target>


<!-- ==================== CodeGen Target ================================== -->
<!--
  
  java -classpath CodeGenerator.jar:okiService.jar:. CodeGenerator CodeGeneratorAPI.gen -a JeffKahn
-->
  <target name="codegen" depends="init" 
    description="Run Code Generator on .GEN files"
  >
    <condition property="codegenlibs.present">
      <and>
        <available file="${extlib.home}\okiCodeGen.jar"/>
      </and>
    </condition>
    
    <echo message="libs.present= ${codegenlibs.present}"/>

    <delete file="osid.dictionary.impl.DictionaryManager.store"/>
    <delete file="osid.shared.impl.SharedImplementation.store"/>
    <delete file="mit.dictionary_en_US.dictionary"/>
    <delete file="mit.dictionary_reversi_US.dictionary"/>
    
    <java classname="osid.util.codegen.demos.CodeGenerator" failonerror="true" fork="true">
      <arg value="${gen.dir}/GUIServices.gen"/>
      <!-- <arg value="-verbose" /> -->
      <classpath>
        <pathelement location="${extlib.home}/okiCodeGen.jar"/>
        <pathelement path="${lib.dir}/okiSID.jar"/>
        <pathelement path="${lib.dir}/okiSIDimpl.jar"/>
        <pathelement path="${build.dir}"/>
        <pathelement path="${java.class.path}"/>
      </classpath>
    </java>
    
    <java classname="osid.util.codegen.demos.CodeGenerator" failonerror="true" fork="true">
      <arg value="${gen.dir}/HelpViewer.gen"/>
      <!-- <arg value="-verbose" /> -->
      <classpath>
        <pathelement location="${extlib.home}/okiCodeGen.jar"/>
        <pathelement path="${lib.dir}/okiSID.jar"/>
        <pathelement path="${lib.dir}/okiSIDimpl.jar"/>
        <pathelement path="${build.dir}"/>
        <pathelement path="${java.class.path}"/>
      </classpath>
    </java>
    
    <java classname="osid.util.codegen.demos.CodeGenerator" failonerror="true" fork="true">
      <arg value="${gen.dir}/MenuToolBar.gen"/>
      <!-- <arg value="-verbose" /> -->
      <classpath>
        <pathelement location="${extlib.home}/okiCodeGen.jar"/>
        <pathelement path="${lib.dir}/okiSID.jar"/>
        <pathelement path="${lib.dir}/okiSIDimpl.jar"/>
        <pathelement path="${build.dir}"/>
        <pathelement path="${java.class.path}"/>
      </classpath>
    </java>
    
    <java classname="osid.util.codegen.demos.CodeGenerator" failonerror="true" fork="true">
      <arg value="${gen.dir}/Preferences.gen"/>
      <!-- <arg value="-verbose" /> -->
      <classpath>
        <pathelement location="${extlib.home}/okiCodeGen.jar"/>
        <pathelement path="${lib.dir}/okiSID.jar"/>
        <pathelement path="${lib.dir}/okiSIDimpl.jar"/>
        <pathelement path="${build.dir}"/>
        <pathelement path="${java.class.path}"/>
      </classpath>
    </java>
    
    <java classname="osid.util.codegen.demos.CodeGenerator" failonerror="true" fork="true">
      <arg value="${gen.dir}/alert.gen"/>
      <!-- <arg value="-verbose" /> -->
      <classpath>
        <pathelement location="${extlib.home}/okiCodeGen.jar"/>
        <pathelement path="${lib.dir}/okiSID.jar"/>
        <pathelement path="${lib.dir}/okiSIDimpl.jar"/>
        <pathelement path="${build.dir}"/>
        <pathelement path="${java.class.path}"/>
      </classpath>
    </java>
    
    <java classname="osid.util.codegen.demos.CodeGenerator" failonerror="true" fork="true">
      <arg value="${gen.dir}/SplashScreen.gen"/>
      <!-- <arg value="-verbose" /> -->
      <classpath>
        <pathelement location="${extlib.home}/okiCodeGen.jar"/>
        <pathelement path="${lib.dir}/okiSID.jar"/>
        <pathelement path="${lib.dir}/okiSIDimpl.jar"/>
        <pathelement path="${build.dir}"/>
        <pathelement path="${java.class.path}"/>
      </classpath>
    </java>
    
    <delete file="osid.dictionary.impl.DictionaryManager.store"/>
    <delete file="osid.shared.impl.SharedImplementation.store"/>
    <delete file="mit.dictionary_en_US.dictionary"/>
    <delete file="mit.dictionary_reversi_US.dictionary"/>
    <delete file="OsidLoader.log"/>

    <!-- The files created by *.gen are moved to the menu package -->
    <move todir="${dist.src}/${rootpkg.dir}/ui">
      <fileset dir="${basedir}">
        <include name="*.java"/>
        <exclude name="SearchButton.java"/>
      </fileset>
    </move>
    <copy todir="${dist.src}/${rootpkg.dir}/ui">
      <fileset dir="${basedir}">
        <include name="SearchButton.java"/>
      </fileset>
    </copy>
    
    <!-- Copy the API javadoc files to the demos package -->
    <copy todir="${dist.src}/${rootpkg.dir}">
      <fileset dir="${basedir}">
        <include name="*.html"/>
      </fileset>
    </copy>
    
  </target>

<!-- ==================== Javadoc Target ================================== -->
<!--

  The "javadoc" target creates Javadoc documentation for the Java
  classes included in your application.  Normally, this is only required
  when preparing a distribution release, but is available as a separate
  target in case the developer wants to create Javadocs independently.

-->

  <target name="javadoc" 
      description="Create Javadoc documentation">

    <mkdir dir="${basedir}/javadoc"/>
    <javadoc additionalparam="-breakiterator" sourcepath="${top.dir}/src"
                destdir="${basedir}/javadoc"
           packagenames="osid/tool">
      <classpath refid="compile.classpath"/>
    </javadoc>
  </target>

</project>

