<!-- use 'ant compile' to just build, 'ant build' to not only compile but make an archive and deprotect everything.  'ant test' runs junit, 'ant chmod_all' deprotects stuff prior to copying
Charley Ruggiero and James Meek 3/06    -->


<project name="a10" default="mainmenu" basedir=".">
    <description>
        use web to handle creation, summary and storage in mysql db of group evaluation resutls
    </description>
  <!-- set global properties for this build -->
<property environment="env"/> <!-- to access eg $CATALINA_HOME -->
<property file="global.properties" />
<filter filtersfile="global.properties"/>

<target name ="mainmenu">
<echo>
Available options:
  clean -- delete all ant-created files
  init  -- clean, create new directories
  compile -- compile java files 
  javadocs  -- create javadocs 
  makewar -- make a war file
  build -- compile, makewar, and deploy   
</echo>
</target>

<path id = "test.classpath">
     <pathelement path ="${build}" />
     <pathelement location ="/www/htdocs/CIS/software/dist/junit3.8.1/junit.jar"/>
</path>

<target name = "build" depends="compile, makewar"/>

<target name="test" >
  <junit fork="yes" haltonfailure="no">
    <batchtest fork="yes"  >
      <fileset dir="${build}">
        <include name="**/*Test.class" />
      </fileset>
      <fileset dir="${src}">
        <include name="**/*Test.class" />
        <include name="**/*Test.java" />
 
      </fileset>
    </batchtest>
  </junit>
</target>


<!-- delete all the (ant created) files in the class directories -->
<target name="clean">
  <delete dir="${build}"/>
</target>

  <target name="init" depends= "clean">
    <!-- Create the time stamp -->
    <tstamp/>
    <!-- Create the build directory structure used by compile -->
    <mkdir dir="${build}"/>
    <mkdir dir="${dist}"/>
  </target>

  <target name="compile" depends="init" >
      <javac classpath="${tomcat_classpath}/servlet-api.jar"
	  srcdir="${src}" 
	  destdir="${build}"/>
      <javac classpath="${tomcat_classpath}/servlet-api.jar"
          srcdir="${src}"
          destdir="${build}"/>
  </target>
  <target name="makewar" >
    <copy todir="dist" file="build.xml"/>
    <copy todir="dist/scripts" filtering="true" >
       <fileset dir="scripts"/> 
    </copy>
    <copy todir="dist/src">
       <fileset dir="${src}" />
    </copy>
    <copy todir="dist/src">
       <fileset dir="${src}" />
    </copy>
     <!-- don't filter binary! -->
    <copy todir="dist/" filtering="false">
      <fileset dir="${web}">
        <include name = "**/*.jar" /> 
      </fileset>  
    </copy>
    <!-- filter everything else -->
    <copy todir="dist/"  filtering = "true">
      <fileset dir="${web}">
         <exclude name = "**/*.jar"/>  
      </fileset> <!-- filtering = changing stuff according to global.prop values-->
    </copy>    
        <copy todir="dist/WEB-INF/classes">
           <fileset dir="${build}" />
        </copy>
    <zip destfile="./a10.war" update= "yes" duplicate="preserve">
        <include name="build.xml"/>
        <fileset dir="dist"/>
    </zip>
   <!-- now put the war file in tomcat; later deprotect it! -->
    <copy file="a10.war"  todir="${webapps}"/>

<delete dir="${dist}"/> <!-- no longer needed -->
  </target>
  <target name="javadocs">
  <javadoc packagenames="com.calendar.*,beans.*,A10Park.*"
           sourcepath="src"
           destdir="javadocs"
           author="true"
           version="true"
           use="true"
           windowtitle="Group G API">
    <doctitle><![CDATA[<h1>Test</h1>]]></doctitle>
    <bottom><![CDATA[<i>Copyright &#169; 2000 Group 10, UD CISC474. All Rights Reserved.</i>]]></bottom>
  </javadoc>
  <chmod   perm="755" >
     <dirset dir="${basedir}/javadocs" />
     <fileset dir="${basedir}/javadocs"/>
  </chmod>
</target>


<target name="tar">
    <tar tarfile="a10.tar" basedir="."
        excludes= "javadocs/**/*.html" 
        includes= "**/*.jsp, **/*.java, **/*.html, **/*.xml, **/*.tld, **/*.jar, **/*.properties"
     />
</target>
</project>



