<project name="Schedule" default="menu" basedir=".">

<property file="global.properties" />
<property environment="env"/>

<path id="custom-classpath">
    <fileset dir="${tomcat.dir}/common/lib">
        <include name="*.jar" />
    </fileset>
    <fileset dir="${tomcat.dir}/common/endorsed">
        <include name="*.jar" />
    </fileset>
    <fileset dir="${junit.dir}/">
        <include name="${junit.jar}" />
    </fileset>

</path>

<target name="menu">
   <echo message="ant clean -- clear out everything but source files" />
   <echo message="ant compile -- compile the Java source" />
   <echo message="ant deploy-doc -- deploy the Javadocs" />
   <echo message="ant doc -- compile the Javadocs" />
   <echo message="ant create-war -- create a war file" />
   <echo message="ant deploy-war -- deploy the war file" />

</target>

<target name="makeBuildDirectory">
    <mkdir dir="${build}"/>
</target>



  <path id="classpath.project">
    <pathelement path="${dir.build}"/>
  </path>

<target name="junit" depends="compile">
    <junit printsummary="yes" haltonfailure="yes">

    <classpath>
      <pathelement location="${build}"/>
    </classpath>

      <test name="edu.udel.pconrad.GuestBook.test.AllTests" />

    </junit>
</target>

<target name="compile" depends="makeBuildDirectory">
    <echo message="Compiling ... "/>

    <javac srcdir="${src}" destdir="${build}"
           includes="**/*.java"> 
      <classpath refid="custom-classpath" />
    </javac>
 
</target>


<target name="doc">
 <javadoc 
   packagenames="edu.udel.pconrad.GuestBook.*"
   sourcepath="${src}"
   destdir="${javadoc.build}"
   author="true" version="true" use="true">
   <classpath refid="custom-classpath" />
 </javadoc>
</target>

<target name="deploy-doc" depends="doc">
   <delete dir="${javadoc.destination}" />

    <!-- copy the generated javadoc to where it should go on the web -->
   
    <copy todir="${javadoc.destination}">
      <fileset dir="${javadoc.build}"/>
    </copy>

    <!-- Change permissions on destination directory, and
         all files and subdirectories under it. -->

     <chmod  perm="a+rx" >
         <dirset dir="${javadoc.destination}" />
         <fileset dir="${javadoc.destination}" />
     </chmod>


</target>



<target name="clean">
  <echo message="Deleting and remaking the output directories." />

  <delete dir="${build}" /> 
  <mkdir dir="${build}" /> 

  <delete dir="${dist}" /> 
  <mkdir dir="${dist}" /> 

  <delete dir="${javadoc.build}" /> 
  <mkdir dir="${javadoc.build}" /> 

</target>


<target name="create-war" description="creates war file" depends="clean, compile">
  <echo message="Creating ${web-app-name}.war" />

  <war destfile="${dist}/${web-app-name}.war" 
       webxml="${etc}/web.xml">
       <classes dir="${build}" />
       <!-- <lib dir="${lib}" -->
       <fileset dir="${web}" />
  </war>
</target>

<target name="deploy-war" depends="create-war">
    <copy todir="${war.destination}">
      <fileset dir="${dist}">
        <include name="${web-app-name}.war" />
      </fileset>
    </copy>
</target>

</project>







