<?xml version="1.0" ?>
<!--
Taken from Core Servlets and JavaServer Pages Volume II
from Prentice Hall and Sun Microsystems Press,
http://volume2.coreservlets.com/.
(C) 2007 Marty Hall, Larry Brown, and Yaakov Chaikin;
may be freely used or adapted.
-->
<project name="Boats" default="compile" basedir=".">
  <description>Web Application: Online Boat Shop</description>
  <property name="javac.deprecation" value="true"/>
  <property name="javac.listfiles" value="false"/>
  <property name="app.name" value="boats"/>

  <!-- Properties for project directories. -->
  <property name="src.dir" location="${basedir}/src"/>
  <property name="lib.dir" location="${basedir}/lib"/>
  <property name="web.dir" location="${basedir}/web"/>
  <property name="build.dir" location="${basedir}/build"/>

  <!-- Properties for build directories. -->
  <property name="build.images.dir"
            location="${build.dir}/images"/>
  <property name="build.webinf.dir"
            location="${build.dir}/WEB-INF"/>
  <property name="build.webinf.classes.dir"
            location="${build.webinf.dir}/classes"/>
  <property name="build.webinf.tlds.dir"
            location="${build.webinf.dir}/tlds"/>

  <!-- The clean target removes the complete build directory
       structure.
  -->
  <target name="clean"
          description="Remove all files from build directory">
    <delete dir="${build.dir}" quiet="true"/>
  </target>

  <!-- The prepare target to create the complete directory
       structure for the Web application. In particular, it
       creates a  build/WEB-INF/classes directory
       necessary for compiling the source files.
  -->
  <target name="prepare"
      description="Create directory structure to build application">
    <mkdir dir="${build.dir}" />
    <mkdir dir="${build.images.dir}" />
    <mkdir dir="${build.webinf.dir}"/>
    <mkdir dir="${build.webinf.classes.dir}"/>
    <mkdir dir="${build.webinf.tlds.dir}"/>
  </target>

  <!-- The copy target copies all Web application files from
       the web directory and subdirectories to the build
       directory. Don't copy backup files (.bak extension).
  -->
  <target name="copy"
          description="Copy Web files to build directory">
    <copy todir="${build.dir}" preservelastmodified="true"
          overwrite="true">
      <fileset dir="${web.dir}">
        <include name="**/*"/>
        <exclude name="**/*.bak"/>
      </fileset>
    </copy>
  </target>

  <!-- Create a path element declaring the directories/files
       to include on the CLASSPATH. Then, define a property to
       the path information.
  -->
  <path id="project.classpath">
    <pathelement location="${lib.dir}/servlet-api.jar"/>
    <pathelement location="${lib.dir}/jsp-api.jar"/>
  </path>
  <property name="classpath" refid="project.classpath"/>

  <!-- Default target that compiles all the source files
       to the build/WEB-INF/classes directory. Ant compiles
       only those .class files that have a different time stamp
       than their corresponding .java files. To compile all
       classes, first run the "clean" target to delete all the
       .class files, then run the "compile" target to recreate
       them.
  -->
  <target name="compile" depends="prepare"
      description="Compile files to WEB-INF/classes directory">
    <javac srcdir="${src.dir}"
           destdir="${build.webinf.classes.dir}"
           listfiles="${javac.listfiles}"
           deprecation="${javac.deprecation}">
      <classpath>
        <pathelement path="${classpath}"/>
      </classpath>
    </javac>
  </target>

  <!-- Target to completely create a clean build of the Web
       application. This target has dependencies on the clean,
       copy, and compile targets to ensure that the built
       application contains new copies of the latest files.
  -->
  <target name="build" depends="clean, prepare, copy, compile"
    description="Creates a clean, complete build of project"/>
</project>