<project name="ps0" basedir="." default="usage">

  <!-- set the classpath for the project        -->
  <!-- this includes your generated class files -->
  <!-- and every jar in the CSE 331 lib directory -->
  <path id="classpath.path">
    <pathelement location="src" />
    <!-- fileset dir="lib">
         <include name="*.jar" />
         </fileset -->
  </path>

  <!-- define some variables for the script -->
  <target name="init">
    <echo>initialize variables for this build file</echo>
    <property name="src" value="${basedir}/ps0" />
    <property name="classes" value="${src}" />
    <property name="doc" value="${basedir}/doc" />
    <property name="api" value="${doc}" />
    <property name="lib" value="${basedir}/lib" />
    <property name="java.api"
              value="http://java.sun.com/javase/6/docs/api/index.html" />
  </target>

  <!-- delete generated files -->
  <target name="clean" depends="init">
    <echo>clean generated files</echo>
    <delete>
      <fileset dir="${classes}" includes="**/*.class" />
    </delete>
    <delete dir="${api}" />
  </target>

  <!-- compile the source code -->
  <target name="compile" depends="init">
    <echo>compile source code</echo>
    <mkdir dir="${classes}" />
    <javac srcdir="${src}"
           destdir="${classes}"
           excludes=".svn,*/package.html">
      <classpath refid="classpath.path" />
    </javac>
  </target>

  <!-- run the javadoc tool on the source code -->
  <target name="javadoc" depends="init">
    <echo>generate javadoc</echo>
    <mkdir dir="${api}" />
    <javadoc sourcepath="${src}"
             packagenames="${ant.project.name}.*"
             destdir="${api}"
             windowtitle="Problem Set 0">
      <classpath refid="classpath.path" />
      <link href="${java.api}" />
      <fileset dir="${src}"></fileset>
    </javadoc>
  </target>

  <!-- export the project as a jar -->
  <target name="build" depends="compile">
    <echo>package the .class files as a .jar file</echo>
    <jar destfile="${basedir}/${ant.project.name}.jar" update="true">
      <fileset dir="${classes}" />
    </jar>
  </target>

  <!-- a user of your script can see the available targets -->
  <target name="usage" depends="init">
    <echo>list the available tasks in this ant script</echo>
    <echo>
      clean:   remove the generated class files and javadoc
      compile: compile the code to class files
      build:   exports the project as a jar
      javadoc: generate javadoc for the source code
      usage:   display this message
    </echo>
  </target>

</project>
