<project name="ps2" basedir="." default="usage">
	
	<!-- set the classpath for the project        -->
	<!-- this includes your generated class files -->
	<!-- and every jar in the 6.170 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}/src" />
		<property name="classes" value="${src}" />
		<property name="lib" value="${basedir}/lib" />
		<property name="doc" value="${basedir}/doc" />
		<property name="api" value="${doc}/api" />
		<property name="java.api"
      value="http://java.sun.com/j2se/1.4.2/docs/api/" />
	</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="CVS,*/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 2"
			 additionalparam="-tagletpath ${lib}/javadoc6170.jar
                              -taglet javadoc6170.RequiresTaglet
                              -taglet javadoc6170.EffectsTaglet
                              -taglet javadoc6170.ModifiesTaglet
                              -taglet javadoc6170.ReturnsTaglet
                              -taglet javadoc6170.SpecfieldTaglet
                              -taglet javadoc6170.DerivedfieldTaglet"
			 stylesheetfile="${doc}/6170-javadoc.css">
			<classpath refid="classpath.path" />
			<link href="${java.api}" />
		</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>

  <!-- use JUnit to run tests -->
   <target name="test" depends="compile">
      <junit printsummary="yes">
        <classpath refid="classpath.path" />
        <formatter type="brief" />
        <batchtest>
           <fileset dir="${src}">
              <include name="**/*Test.java" />
           </fileset>
        </batchtest>
      </junit>
   </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
test:    runs JUnit test suite
build:   exports the project as a jar
javadoc: generate javadoc for the source code
usage:   display this message
		</echo>
	</target>

</project>

