<!-- build configuration -->
<project name="viztool" default="compile" basedir=".">

  <!-- things you may want to change -->
  <property name="app.name"         value="viztool"/>
  <property name="doc.packages"     value="com.samskivert.*"/>
  <property name="doc.overview" value="com/samskivert/viztool/overview.html"/>
  <property name="copyright.holder" value="Michael Bayne"/>
  <property name="build.compiler"   value="jikes"/>
  <property name="java.libraries"   value="/usr/share/java"/>

  <!-- things you probably don't want to change -->
  <property name="src.dir"     value="src/java"/>
  <property name="deploy.dir"  value="dist"/>
  <property name="dist.jar"    value="${app.name}.jar"/>
  <property name="javadoc.dir" value="${deploy.dir}/docs"/>
  <property name="savedoc.dir" value="docs"/>

  <!-- declare our classpath business -->
  <path id="base.classpath">
    <pathelement location="${deploy.dir}/classes"/>
    <fileset dir="lib" includes="**/*.jar"/>
  </path>
  <path id="classpath">
    <path refid="base.classpath"/>
  </path>

  <!-- include JAVA_LIBS jars in our classpath if it exists -->
  <target name="check-java-libs" if="env.JAVA_LIBS">
    <!-- overwrite the classpath with one that contains JAVA_LIBS jars -->
    <path id="classpath">
      <path refid="base.classpath"/>
      <fileset dir="${env.JAVA_LIBS}" includes="**/*.jar"/>
    </path>
  </target>

  <!-- prepares the application directories -->
  <target name="prepare">
    <mkdir dir="${deploy.dir}"/>
    <mkdir dir="${deploy.dir}/classes"/>
    <mkdir dir="${javadoc.dir}"/>
    <copy todir="${deploy.dir}/classes">
      <fileset dir="${src.dir}" includes="**/*.properties"/>
    </copy>
  </target>

  <!-- cleans out the installed application -->
  <target name="clean">
    <delete dir="${deploy.dir}"/>
  </target>

  <!-- build the java class files -->
  <target name="compile" depends="prepare">
    <javac srcdir="${src.dir}" destdir="${deploy.dir}/classes"
           debug="on" optimize="off" deprecation="off">
      <classpath refid="classpath"/>
    </javac>
  </target>

  <!-- build the javadoc documentation -->
  <target name="javadoc" depends="prepare">
    <javadoc sourcepath="${src.dir}"
             packagenames="${doc.packages}"
             windowtitle="${app.name} API"
             doctitle="${app.name} API"
             overview="${src.dir}/${doc.overview}"
             bottom="Copyright &#169; 2001 ${copyright.holder}. All Rights Reserved."
             destdir="${javadoc.dir}"
             additionalparam="-breakiterator">
      <classpath refid="classpath"/>
      <link href="http://samskivert.com/code/samskivert/samskivert/dist/api"/>
      <link href="http://java.sun.com/j2se/1.4/docs/api/"/>
    </javadoc>
  </target>

  <!-- builds the javadocs and stuffs them in a directory where they won't
       be blown away when we do "clean" next time -->
  <target name="savedoc" depends="javadoc">
    <delete dir="${savedoc.dir}/api"/>
    <copy todir="${savedoc.dir}/api">
      <fileset dir="${javadoc.dir}" includes="**/*"/>
    </copy>
  </target>

  <!-- a target for rebuilding everything -->
  <target name="all" depends="clean,prepare,compile,javadoc,dist"/>

  <!-- builds our distribution files (war and jar) -->
  <target name="dist" depends="prepare,compile">
    <jar file="${deploy.dir}/${dist.jar}"
         basedir="${deploy.dir}/classes"/>
  </target>

  <!-- invoke the visualizer on itself for testing -->
  <target name="sumtest" depends="prepare,compile">
    <taskdef name="viztool" classname="com.samskivert.viztool.DriverTask"/>
    <viztool visualizer="com.samskivert.viztool.summary.SummaryVisualizer"
      pkgroot="com.samskivert.viztool"
      classes="com.samskivert.viztool.*">
      <classpath refid="classpath"/>
    </viztool>
  </target>

  <target name="hiertest" depends="prepare,compile">
    <taskdef name="viztool" classname="com.samskivert.viztool.DriverTask"/>
    <viztool visualizer="com.samskivert.viztool.hierarchy.HierarchyVisualizer"
      pkgroot="com.samskivert.viztool"
      classes="com.samskivert.viztool.*"
      output="hiertest.ps">
      <classpath refid="classpath"/>
    </viztool>
  </target>

</project>
