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

  <!-- things you may want to change -->
  <property name="app.name"         value="atlanti"/>
  <property name="doc.packages"     value="com.threerings.atlanti.*"/>
  <property name="doc.overview"     value="com/threerings/atlanti/overview.html"/>
  <property name="copyright.holder" value="Michael Bayne"/>
  <property name="narya.home"       value="../../work/narya"/>

  <!-- 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="gendobj.path" value="${narya.home}/bin/gendobj"/>

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

  <!-- generates .java files for all .dobj files -->
  <target name="gendobj">
    <apply executable="${gendobj.path}" failonerror="true">
      <srcfile/>
      <fileset dir="src/java" includes="**/*.dobj"/>
    </apply>
  </target>

  <!-- prepares the application directories -->
  <target name="prepare" depends="gendobj">
    <mkdir dir="${deploy.dir}"/>
    <mkdir dir="${deploy.dir}/classes"/>
    <mkdir dir="${deploy.dir}/classes/rsrc"/>
    <mkdir dir="${javadoc.dir}"/>
    <copy todir="${deploy.dir}/classes">
      <fileset dir="${src.dir}" includes="**/*.properties"/>
    </copy>
    <copy todir="${deploy.dir}/classes/rsrc">
      <fileset dir="rsrc" includes="**/*"/>
    </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="on">
      <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://java.sun.com/j2se/1.3/docs/api/"/>
    </javadoc>
  </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>

</project>
