Java/Ant/Tar

Материал из Java эксперт
Версия от 06:36, 1 июня 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Create tar file

 
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.    
#
# This file is used by build.xml 
#
# Global defaults
name=          Anakia
project=       anakia
version=       1.0
final.name=    ${project}-${version}
root.package=  org.apache.anakia
# compile switches
debug= on
optimize= on
deprecation= off
ant.build.dir= build
build.dir= ${app.dir}/bin
# The source tree runs through a filter copy task to
# allow substitution of version, date etc. and will
# end up in build.src
build.lib=       ${build.dir}/lib
build.test.lib=  ${build.dir}/test-lib
build.dest=      ${build.dir}/classes
build.test.dest= ${build.dir}/test-classes
build.javadoc=   ${build.dir}/apidocs
build.test=      ${build.dir}/test
build.docs=      ${build.dir}/docs
# Various local pathes in the distribution
src.java.dir=  ${app.dir}/src/java
test.java.dir= ${app.dir}/src/test
test.dir=      ${app.dir}/test
example.dir=   ${app.dir}/examples
xdocs.dir=     ${app.dir}/xdocs
# Running the tests
test.haltonerror= true
test.haltonfailure= true
# Building the distribution
dist.root= ${build.dir}/dist
dist.dir= ${dist.root}/${final.name}
# Set to Sun Javadocs
javadocs.ref.jsdk= http://java.sun.ru/j2se/1.4.2/docs/api/
# for the javadoc
javadoc.packagenames = ${root.package}.*
# attributes for the jar manifest
mf.package = ${root.package}
mf.extension.name = ${project}
mf.specification.title = Anakia is a XML-based text processor
mf.specification.vendor = Apache Software Foundation
mf.implementation.title = ${mf.package}
mf.implementation.vendor.id = org.apache
mf.implementation.vendor = Apache Software Foundation
mf.implementation.version = ${version}

# #######################################################################
#
# Downloading jars from ibiblio repository
#
# #######################################################################
# The default behaviour is to download dependency jars only when
# they are not already present.
# Set skip.jar.loading to true to never download any dependency jar,
# or force.jar.loading to true to always download all dependency jars.
skip.jar.loading= false
force.jar.loading= false
#
# Settings for the proxy to use for download. Change this if you must
# use a proxy from your host. If the proxy.host property is unset, no
# proxy is used.
proxy.host=
proxy.port= 80
#
# We download directly from the ibiblio maven repository
repo.url= http://www.ibiblio.org/maven
#
# Jars to be downloaded
jar.antlr.version= 2.7.5
jar.rumons-collections.version= 3.1
jar.rumons-lang.version= 2.1
jar.jdom.version= 1.0
jar.werken-xpath.version= 0.9.4
jar.junit.version= 3.8.1
jar.velocity.version= 1.5

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at
   http://www.apache.org/licenses/LICENSE-2.0
 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.    
-->
<!-- Build file for project -->
<!-- This project has its basedir set to the root directory   -->
<!-- of the project distribution. This is necessary so that   -->
<!-- all the code that uses relative directory references     -->
<!-- (like the tests) can be run in the same way when using   -->
<!-- the ant based build and the maven based build.           -->
<!-- *** DO NOT CHANGE THIS SETTING LIGHTLY! ***              -->
<project name="Anakia" default="world" basedir="..">
  <path id="basedir-os">
    <pathelement location="${basedir}" />
  </path>
  <!-- This is the relative base dir. This must be the root of the   -->
  <!-- distribution. All relative pathes are prefixed with      -->
  <!-- app.dir                                                  -->
  <pathconvert property="app.dir" refid="basedir-os" targetos="unix"/>
  <!-- Give user a chance to override without editing this file
       (and without typing -D each time it compiles it -->
  <property file="${user.home}/.ant.properties" />
  <property file="${user.home}/build.properties" />
  <property file=".ant.properties" />
  <!-- This file contains all the defaults for the build  -->
  <property file="build/build.properties" />

  <property name="test.runner" value="junit.textui.TestRunner"/>
  <target name="world" depends="jar,test,javadocs,docs,env"
          description="Build the project jar and documentation"/>
  
  <!-- prints the environment                                              -->
  
  <target name="env" description="Prints build parameters">
    <echo>
  Global settings:
    java.home = ${java.home}
    user.home = ${user.home}
    java.class.path = ${java.class.path}
  Project settings:
    Version:     ${version}
    Debug:       ${debug}
    Optimize:    ${optimize}
    Deprecation: ${deprecation}
  Target settings (relative to build tree root):
    Classes:      ${build.dest}
    API Docs:     ${build.javadoc}
    Docs:         ${build.docs}
    </echo>
  </target>
  
  <!-- Prepares the build directory                                        -->
  
  <target name="prepare" depends="basic-prepare"/>
  
  <!-- sets up the build trees for sources and tests                       -->
  
  <target name="basic-prepare">
    <mkdir dir="${build.dir}"/>
    <mkdir dir="${build.dest}"/>
    <mkdir dir="${build.test.dest}"/>
  </target>
  
  <!-- sets up the build environment (classpath and libs)                  -->
  
  <target name="build-prepare" depends="basic-prepare">
    <ant antfile="${ant.build.dir}/download.xml" target="build-download" />
    <!-- Build classpath -->
    <path id="build.classpath">
      <fileset dir="${build.lib}">
        <include name="**/*.jar"/>
      </fileset>
    </path>
    <!-- Test classpath, contains dependencies needed only for Testing -->
    <path id="test.classpath">
        <fileset dir="${build.test.lib}">
          <include name="**/*.jar"/>
        </fileset>
        <fileset dir="${build.lib}">
          <include name="**/*.jar"/>
        </fileset>
        <pathelement location="${build.dest}" />
        <pathelement location="${build.test.dest}" />
    </path>
    <path id="run.classpath">
      <path refid="build.classpath"/>
      <pathelement location="${build.dir}/${final.name}.jar"/>
    </path>
  </target>
  
  <!-- Compiles the source tree and the tests                              -->
  
  <target name="compile" depends="compile-src,compile-test"/>
  <target name="compile-src" depends="build-prepare"
          description="Compiles the source">
    <javac srcdir="${src.java.dir}"
      destdir="${build.dest}"
      encoding="UTF-8"
      debug="${debug}"
      deprecation="${deprecation}"
      optimize="${optimize}"
      classpathref="build.classpath"/>
    <copy todir="${build.dest}" filtering="yes">
      <fileset dir="${src.java.dir}">
        <include name="**/*.properties"/>
      </fileset>
    </copy>
  </target>
  <target name="compile-test" depends="build-prepare,compile-src"
          description="Compiles the test classes">
    <javac srcdir="${test.java.dir}"
      destdir="${build.test.dest}"
      encoding="UTF-8"
      debug="${debug}"
      deprecation="${deprecation}"
      optimize="${optimize}">
      <!-- Don"t use the run classpath, build using the exploded class tree -->
      <classpath>
        <path refid="build.classpath"/>
        <path refid="test.classpath" />
        <pathelement location="${build.dest}"/>
      </classpath>
    </javac>
    <copy todir="${build.test.dest}" filtering="yes">
      <fileset dir="${test.java.dir}">
        <include name="**/*.properties"/>
      </fileset>
    </copy>
  </target>

  
  <!-- Compiles the source directory and creates a .jar file               -->
  
  <target name="jar" depends="compile-src"
          description="Builds the Jar file">
    <property name="jarname" value="${final.name}" />
    <jar jarfile="${build.dir}/${jarname}.jar">
      <metainf dir="${app.dir}">
        <include name="LICENSE"/>
        <include name="NOTICE"/>
      </metainf>
      <fileset dir="${build.dest}"/>
      <manifest>
        <attribute name="Created-By" value="Apache Ant"/>
        <attribute name="Build-Jdk" value="${java.version}"/>
        <attribute name="Package" value="${mf.package}"/>
        <attribute name="Extension-Name" value="${mf.extension.name}"/>
        <attribute name="Specification-Title" value="${mf.specification.title}" />
        <attribute name="Specification-Vendor" value="${mf.specification.vendor}"/>
        <attribute name="Implementation-Title" value="${mf.implementation.title}"/>
        <attribute name="Implementation-Vendor-Id" value="${mf.implementation.vendor.id}"/>
        <attribute name="Implementation-Vendor" value="${mf.implementation.vendor}"/>
        <attribute name="Implementation-Version" value="${mf.implementation.version}"/>
      </manifest>
    </jar>
    <checksum file="${build.dir}/${jarname}.jar" algorithm="md5" property="checksum.jar.md5"/>
    <checksum file="${build.dir}/${jarname}.jar" algorithm="sha1" property="checksum.jar.sha1"/>
    <echo message="${checksum.jar.md5} *${jarname}.jar" file="${build.dir}/${jarname}.jar.md5" />
    <echo message="${checksum.jar.sha1} *${jarname}.jar" file="${build.dir}/${jarname}.jar.sha1" />
  </target>
  
  <!-- jars the source                                                    -->
  
  <target name="jar-src"
          depends="prepare"
          description="Builds the Source Jar File">
    <jar jarfile="${build.dir}/${final.name}-src.jar">
      <metainf dir="${app.dir}">
        <include name="LICENSE"/>
        <include name="NOTICE"/>
      </metainf>
      <fileset dir="${src.java.dir}"/>
      <manifest>
        <attribute name="Created-By" value="Apache Ant"/>
        <attribute name="Specification-Title" value="${mf.specification.title}" />
        <attribute name="Specification-Vendor" value="${mf.specification.vendor}"/>
        <attribute name="Implementation-Title" value="${mf.implementation.title}"/>
        <attribute name="Implementation-Vendor-Id" value="${mf.implementation.vendor.id}"/>
        <attribute name="Implementation-Vendor" value="${mf.implementation.vendor}"/>
        <attribute name="Implementation-Version" value="${mf.implementation.version}"/>
      </manifest>
    </jar>
    <checksum file="${build.dir}/${final.name}-src.jar" algorithm="md5" property="checksum.jar-src.md5"/>
    <checksum file="${build.dir}/${final.name}-src.jar" algorithm="sha1" property="checksum.jar-src.sha1"/>
    <echo message="${checksum.jar-src.md5} *${final.name}-src.jar" file="${build.dir}/${final.name}-src.jar.md5" />
    <echo message="${checksum.jar-src.sha1} *${final.name}-src.jar" file="${build.dir}/${final.name}-src.jar.sha1" />
  </target>
  
  <!-- Creates the API documentation                                       -->
  
  <target name="javadocs" depends="build-prepare"
          description="Creates the Javadoc API documentation">
    <mkdir dir="${build.javadoc}"/>
    <javadoc sourcepath="${src.java.dir}"
             packagenames="${javadoc.packagenames}"
             destdir="${build.javadoc}"
             author="true"
             private="false"
             version="true"
             use="true"
             windowtitle="${name} ${version} API"
             doctitle="${name} ${version} API"
             encoding="UTF-8"
             docencoding="UTF-8"
             bottom="Copyright &#169; 2000-${build.year} &lt;a href=&quot;http://www.apache.org/&quot;&gt;Apache Software Foundation&lt;/a&gt;. All Rights Reserved."
             classpathref="build.classpath">
      <link href="${javadocs.ref.jsdk}"/>
      <link href="http://www.jdom.org/docs/apidocs"/>
      <link href="http://logging.apache.org/log4j/docs/api"/>
      <link href="http://excalibur.apache.org/apidocs"/>
      <link href="http://tomcat.apache.org/tomcat-4.1-doc/servletapi"/>
      <link href="http://jakarta.apache.org/oro/api"/>
      <link href="http://jakarta.apache.org/commons/lang/api-release"/>
      <link href="http://jakarta.apache.org/commons/collections/api-release"/>
    </javadoc>
  </target>
  <target name="javadocs-clean">
    <delete dir="${build.javadoc}" quiet="true"/>
  </target>
  
  <!-- Package                                                             -->
  
  <target name="build-package-tree" depends="clean,jar,docs,javadocs">

    <mkdir dir="${dist.dir}"/>
    <mkdir dir="${dist.dir}/src/java"/>
    <copy todir="${dist.dir}/src/java/">
      <fileset dir="${src.java.dir}" />
    </copy>
    <copy todir="${dist.dir}/src/test/">
      <fileset dir="${test.java.dir}" />
    </copy>
    <copy todir="${dist.dir}/lib">
      <fileset dir="${build.lib}" />
    </copy>
    <copy todir="${dist.dir}/lib/test">
      <fileset dir="${build.test.lib}" />
    </copy>
    <copy todir="${dist.dir}/build">
      <fileset dir="${app.dir}/build">
        <include name="**"/>
        <exclude name="velocity.log"/>
      </fileset>
    </copy>
    <!-- Copy docs, exclude API docs -->
    <copy todir="${dist.dir}/docs">
      <fileset dir="${build.docs}">
        <include name="**"/>
        <exclude name="docs/api/**"/>
      </fileset>
    </copy>
    <!-- Add freshly built Java docs -->
    <copy todir="${dist.dir}/docs/api">
      <fileset dir="${build.javadoc}">
        <include name="**"/>
      </fileset>
    </copy>
    <copy todir="${dist.dir}/test">
      <fileset dir="${app.dir}/test">
        <include name="**"/>
      </fileset>
    </copy>
    <copy todir="${dist.dir}/xdocs">
      <fileset dir="${xdocs.dir}">
        <include name="**"/>
      </fileset>
    </copy>
    <copy todir="${dist.dir}">
      <fileset dir="${app.dir}">
        <include name="LICENSE" />
        <include name="NOTICE" />
        <include name="README.txt" />
        <include name="pom.xml" />
      </fileset>
    </copy>
    <copy
      file="${build.dir}/${final.name}.jar"
      tofile="${dist.dir}/${final.name}.jar"
    />
  </target>
  
  <!-- Packages the distribution with ZIP                                 -->
  
  <target name="package-zip"
          depends="build-package-tree">
    <!-- .zip built for Windows -->
    <fixcrlf srcdir="${dist.dir}" eol="crlf" eof="asis" encoding="ISO-8859-1">
      <include name="**/*.html" />
      <include name="**/*.java" />
      <include name="**/*.properties" />
      <include name="**/*.txt" />
      <include name="**/*.xml" />
    </fixcrlf>
    <delete file="${build.dir}/${final.name}.zip" quiet="true"/>
    <zip zipfile="${build.dir}/${final.name}.zip" basedir="${dist.root}"
         includes="**/${final.name}/**"/>
    <checksum file="${build.dir}/${final.name}.zip" algorithm="md5" property="checksum.zip.md5"/>
    <checksum file="${build.dir}/${final.name}.zip" algorithm="sha1" property="checksum.zip.sha1"/>
    <echo message="${checksum.zip.md5} *${final.name}.zip" file="${build.dir}/${final.name}.zip.md5" />
    <echo message="${checksum.zip.sha1} *${final.name}.zip" file="${build.dir}/${final.name}.zip.sha1" />
  </target>
  
  <!-- Packages the distribution with TAR-GZIP                            -->
  
  <target name="package-tgz"
          depends="build-package-tree">
    <!-- .tar.gz built for Unix -->
    <fixcrlf srcdir="${dist.dir}" eol="lf" eof="remove" encoding="ISO-8859-1">
      <include name="**/*.html" />
      <include name="**/*.java" />
      <include name="**/*.properties" />
      <include name="**/*.txt" />
      <include name="**/*.xml" />
    </fixcrlf>
    <delete file="${build.dir}/${final.name}.tar.gz" quiet="true"/>
    <tar tarfile="${build.dir}/${final.name}.tar.gz" basedir="${dist.root}"
         includes="**/${final.name}/**" longfile="gnu" compression="gzip" />
    <checksum file="${build.dir}/${final.name}.tar.gz" algorithm="md5" property="checksum.tgz.md5"/>
    <checksum file="${build.dir}/${final.name}.tar.gz" algorithm="sha1" property="checksum.tgz.sha1"/>
    <echo message="${checksum.tgz.md5} *${final.name}.tar.gz" file="${build.dir}/${final.name}.tar.gz.md5" />
    <echo message="${checksum.tgz.sha1} *${final.name}.tar.gz" file="${build.dir}/${final.name}.tar.gz.sha1" />
  </target>

  
  <!-- Packages the distribution with ZIP and TAR-GZIP                    -->
  
  <target name="package"
          depends="package-zip,package-tgz"
          description="Generates the distribution files">
  </target>
  
  
  <!-- Cleans up the build directory. Leave Libs unharmed to avoid re-download -->
  
  <target name="clean" 
          description="Cleans all generated files except downloaded libs">
    <delete includeEmptyDirs="true" quiet="true">
      <fileset dir="${build.dir}" defaultexcludes="no">
        <exclude name="lib/**" />
        <exclude name="test-lib/**" />
      </fileset>
      <fileset dir="${ant.build.dir}" defaultexcludes="no">
        <include name="velocity.log" />
      </fileset>
    </delete>
  </target>
  
  <!-- Really cleans up the build directory                                -->
  
  <target name="real-clean" 
          description="Cleans all generated files">
    <delete includeEmptyDirs="true" quiet="true" dir="${build.dir}" />
  </target>
  
  <!-- Make HTML version of the documentation                         -->
  
  <target name="docs" depends="build-prepare,jar"
          description="Generates the HTML documentation">
    <taskdef name="anakia"
             classname="org.apache.anakia.AnakiaTask"
             classpathref="run.classpath"/>
    <echo>
  #######################################################
  #
  #  Now using Anakia to transform the XML documentation
  #  to HTML.
  #######################################################
    </echo>
    <anakia basedir="${xdocs.dir}/docs" destdir="${build.docs}"
         extension=".html" style="site.vsl"
         projectFile="../stylesheets/project.xml"
         includes="**/*.xml"
         lastModifiedCheck="true"
         templatePath="${xdocs.dir}/stylesheets">
    </anakia>
    <copy todir="${build.docs}/images" filtering="no">
        <fileset dir="${xdocs.dir}/images">
            <include name="**/*.gif"/>
            <include name="**/*.jpeg"/>
            <include name="**/*.jpg"/>
            <include name="**/*.png"/>
        </fileset>
    </copy>
    <copy todir="${build.docs}" filtering="no">
        <fileset dir="${xdocs.dir}">
            <include name="**/*.css"/>
            <include name="**/.htaccess"/>
        </fileset>
    </copy>
  </target>

  
  <!-- Cleans up the docs directory                                       -->
  
  <target name="docs-clean">
    <delete dir="${build.docs}" quiet="true"/>
  </target>

  
  <!-- JUnit Tests                                                         -->
  
  <target name="test-clean">
    <delete dir="${build.test.dest}" quiet="true"/>
    <delete dir="${build.test}" quiet="true"/>
    <delete dir="${build.test.reports}" quiet="true"/>
  </target>

  <target name="test"
          depends="build-prepare,compile-test,test-anakia"/>

  <target name="test-anakia">
    <echo message="Running Anakia tests..."/>
    <taskdef name="anakia" classname="org.apache.anakia.AnakiaTask"
             classpathref="test.classpath"/>
    <!-- run twice - once with custom context and once without -->
    <anakia basedir="${test.dir}/anakia/xdocs"
            destdir="${build.test}/anakia"
        extension=".html" style="./site_contexts.vsl"
        projectFile="./stylesheets/project.xml"
        excludes="**/stylesheets/**"
        includes="**/*.xml"
        templatePath="${test.dir}/anakia/xdocs/stylesheets"
        lastModifiedCheck="false">
    </anakia>
    <anakia basedir="${test.dir}/anakia/xdocs"
            destdir="${build.test}/anakia"
        extension=".context.html" style="./site_contexts.vsl"
        projectFile="./stylesheets/project.xml"
        excludes="**/stylesheets/**"
        includes="**/*.xml"
        templatePath="${test.dir}/anakia/xdocs/stylesheets"
        lastModifiedCheck="false">
        <context name="customContext" file="./stylesheets/customContext.xml"/>
    </anakia>
    <java classname="${test.runner}" fork="yes" dir="${app.dir}" failonerror="${test.haltonerror}"
          classpathref="test.classpath">
      <arg value="org.apache.anakia.AnakiaTestCase"/>
    </java>
  </target>

</project>





Tar the binary distribution with the documentation

 
<?xml version="1.0"?>
<project name="Example Application Build" default="build-both" basedir=".">
  
  <property file="build.properties"/>
  <!-- CVSROOT for the JSTL -->
  <property name="cvsroot" 
            value=":pserver:anoncvs@cvs.apache.org:/home/cvspublic" />
  <!-- CVSROOT for the MySQL connector -->
  <property name="mysql.cvsroot" 
            value=":pserver:anonymous@cvs.sourceforge.net:/cvsroot/mmmysql" />
  <!-- The master build classpath          --> 
  <path id="build.classpath">
    <pathelement location="${servlet24.jar}"/>
    <pathelement location="${jsp20.jar}"/>
    <pathelement location="${mysql.jar}"/>
    <pathelement path="${appName.jar}"/>
  </path>
  <!-- Javadoc file sets                   --> 
  <fileset id="javadoc" dir="${src}">
    <exclude name="*/conf/**"/>
    <exclude name="*/docs/*"/>
    <include name="shared/**"/>
    <include name="stand-alone/**"/>
    <include name="web/java/**"/>
  </fileset>  
  <!-- Properties and pattern sets for the packaging targets --> 
  <!-- The value of each property in this section is the setting -->
  <!-- for the "dir" attribute of file sets and tar file sets --> 
  <!-- Property and pattern set for the documentation -->
  <property name="docs.all.dir" value="${build}"/>
  <!-- Tar file sets cannot use file sets, so we must use a pattern set -->
  <patternset id="docs.all">
    <include name="docs/**"/>
  </patternset>
  <!-- Property and pattern set for the license and README -->
  <property name="docs.misc.dir" value="${src}/shared/docs"/>
  <!-- Tar file sets cannot use file sets, so we must use a pattern set -->
  <patternset id="docs.misc">
    <include name="README"/>
    <include name="LICENSE"/>
  </patternset>
  
  <!-- Property and pattern set for the source, -->
  <!-- build.xml, and build.properties -->
  <property name="src.files.dir" value="."/>
  <!-- Tar file sets cannot use file sets, so we must use a pattern set -->
  <patternset id="src.files">
    <include name="${src}/**"/>
    <include name="build.*"/>
  </patternset>
  <!-- Pattern set for the binary JAR -->
  <!-- Nothing else is needed because the directory that contains it -->
  <!-- is already in the ${dist} property and it"s used in a zip file set -->
  <!-- as well as a tar file set --> 
  <patternset id="bin.jar">
    <include name="*.jar"/>
  </patternset>
  <!-- Pattern set for the binary WAR -->
  <!-- Nothing else is needed because the directory that contains it -->
  <!-- is already in the ${dist} property and it"s used in a zip file set -->
  <!-- as well as a tar file set --> 
  <patternset id="bin.war">
    <include name="*.war"/>
  </patternset>
  <!-- Initialization target               --> 
  <!-- Create the working directories -->
  <target name="dir" description="Create the working directories">
    <echo message="Creating the working directories"/>
    <mkdir dir="${build.stand-alone.root}"/>
    <mkdir dir="${build.web.classes}"/>
    <mkdir dir="${dist}"/>
    <mkdir dir="${lib}"/>
  </target>
  <!-- CVS and build tasks for the JSTL and MySQL connector -->
  <!-- Update or check out required sources from CVS for the JSTL -->
  <target name="checkout-jstl" depends="dir" 
          description="Update or check out required sources
                       from CVS for the JSTL">
    <echo message="Checking out the required JSTL sources from CVS"/>
    <cvs cvsroot="${cvsroot}" quiet="true"
         command="checkout -P ${jstl.build}" 
         dest="${build}" compression="true" />
  </target>
  <!-- Update or check out required sources from CVS for the MySQL connector -->
  <target name="checkout-mysql-connector" depends="dir" 
          description="Update or check out required sources
          from CVS for the MySQL connector">
    <echo message="Checking out the required sources from CVS for the MySQL connector" />
    <cvs cvsroot="${mysql.cvsroot}" quiet="true"
         command="checkout" package="${mysql.build}"
         dest="${build}" compression="true" />
  </target>
  <!-- Build the JSTL from source -->
  <target name="build-jstl" depends="checkout-jstl" 
          description="Build the JSTL from source">
    <echo message="Building the JSTL from source"/>
    <ant antfile="build.xml" dir="${build}/${jstl.build}"/>
    <copy todir="${lib}">
      <fileset dir="${build}/${jstl.build}/${build}/lib">
        <include name="*.jar"/>
      </fileset>
    </copy>
  </target>
  <!-- Build the MySQL connector from source -->
  <target name="build-mysql-connector" depends="checkout-mysql-connector" 
          description="Build the MySQL connector from source">
    <echo message="Building the MySQL connector from source"/>
    <!-- The MySQL connector file needs this directory to exist -->
    <!-- Therefore we need to create it -->
    <mkdir dir="${build}/dist-mysql-jdbc"/>
    <ant antfile="build.xml" dir="${build}/${mysql.build}"/>
    <copy tofile="${mysql.jar}">
      <fileset dir="${build}/build-mysql-jdbc">
        <include name="mysql-connector*/*.jar"/>
      </fileset>
    </copy>
  </target>
  <!-- Compile the stand-alone application -->
  <target name="compile-stand-alone" depends="dir" 
          description="Compile stand-alone application">
    <echo message="Compiling the stand-alone application"/>
    <javac srcdir="${src.shared.java}" destdir="${build.stand-alone.root}"/>
    <javac srcdir="${src.stand-alone.java}" 
           destdir="${build.stand-alone.root}"/>  
  </target>
<!--
  <target name="stand-alone-complete" 
          description="Compile stand-alone application, 
          using CVS version of the MySQL connector">
    <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/>
    <antcall target="build-mysql-connector"/>
    <antcall target="package-stand-alone"/>
  </target>
  <target name="stand-alone-complete" 
          depends="build-mysql-connector, package-stand-alone" 
          description="Compile stand-alone application, 
          using CVS version of the MySQL connector">
    <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/>
  </target> 
-->
  <target name="stand-alone-complete" 
          depends="build-mysql-connector, package-stand-alone" 
          description="Compile stand-alone application, 
                       using CVS version of the MySQL connector">
    <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/>
  </target>
  <!-- Package the stand-alone application -->
  <target name="package-stand-alone" depends="compile-stand-alone" 
          description="Package the stand-alone application">
    <echo message="Creating the stand-alone JAR file"/>
    <copy file="${database.properties}" todir="${build.stand-alone.root}"/>
    <jar destfile="${appName.jar}" basedir="${build.stand-alone.root}"/>
  </target>
  <!-- Compile the web application -->
  <target name="compile-web" depends="dir" description="Compile web application">
    <echo message="Compiling the web application"/>
    <javac destdir="${build.web.classes}">
      <src path="${src.shared.java}"/>
    </javac>
    <javac srcdir="${src.web.java}" destdir="${build.web.classes}">
      <classpath refid="build.classpath"/>
    </javac>
  </target>
<!--
  <target name="web-complete" 
          description="Compile web application, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling web application, using CVS versions of the MySQL connector and the JSTL"/>
    <antcall target="build-mysql-connector"/>
    <antcall target="build-jstl"/>
    <antcall target="package-web"/>
  </target>
  <target name="web-complete" 
          depends="build-mysql-connector, build-jstl, package-web" 
          description="Compile web application, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiled web application, using CVS versions of the MySQL connector and the JSTL"/>
  </target>
-->
  <target name="web-complete" 
          depends="build-mysql-connector, build-jstl, package-web" 
          description="Compile web application, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling web application, using CVS versions of the MySQL connector and the JSTL"/>
  </target>
  <!-- Copy the web pages and configuration files -->
  <target name="copy-web" depends="compile-web" description="Copy the web files">
    <echo message="Copying the web pages and configuration files"/>
    <copy todir="${build.web.root}">
      <fileset dir="${src.web.pages}"/>
    </copy>
    <!-- Copy the tags -->
    <copy todir="${build.web.tags}">
      <fileset dir="${src.web.tags}"/>
    </copy>
    <copy todir="${build.web.web-inf}">
      <fileset dir="${src.web.conf}">
        <include name="*.tld"/>
      </fileset>
    </copy>
    <!-- Copy the JAR files -->
    <copy todir="${build.web.lib}">
      <fileset dir="${lib}"/>
    </copy>
    <!-- Copy the properties file -->
    <copy file="${database.properties}" todir="${build.web.classes}"/>
    <!-- No need to copy web.xml, as the WAR task does this for us -->
  </target>
  <!-- Build the WAR file -->
<!--
  <target name="package-web" depends="copy-web" description="Build the WAR">
    <echo message="Building the WAR file"/> 
    <war destfile="${appName.war}" basedir="${build.web.root}" 
         webxml="${src.web.conf}/web.xml"/>
  </target>
-->
  <!-- Build the WAR file in one step -->
  <target name="package-web" depends="compile-web" 
          description="Build the WAR file in one step">
    <echo message="Building the WAR file in one step"/> 
    <war destfile="${appName.war}" basedir="${src.web.pages}" 
         webxml="${src.web.conf}/web.xml">
      <lib dir="${lib}"/>
      <classes dir="${build.web.root}"/>
      <zipfileset dir="${src.web.tags}" prefix="WEB-INF/tags"/>
      <zipfileset file="${database.properties}" prefix="WEB-INF/classes"/>
      <zipfileset dir="${src.web.conf}" prefix="WEB-INF">
        <include name="*.tld"/>
      </zipfileset>
    </war>
  </target>
  <!-- Targets that work with both applications -->
<!--
  <target name="build-both" 
          description="Compile both applications, 
                       without CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling both applications, without CVS versions of the MySQL connector and the JSTL"/>
    <antcall target="package-stand-alone"/>
    <antcall target="package-web"/>
  </target>
  <target name="build-all" 
          description="Compile both applications, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling both applications, using CVS versions of the MySQL connector and the JSTL"/>
    <antcall target="stand-alone-complete"/>
    <antcall target="web-complete"/>
  </target>
-->
  <target name="build-both" 
          depends="package-stand-alone, package-web" 
          description="Compile both applications, 
                       without CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiled both applications, without CVS versions of the MySQL connector and the JSTL"/>
  </target>
  <target name="build-all" 
          depends="stand-alone-complete, web-complete" 
          description="Compile both applications, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiled both applications, using CVS versions of the MySQL connector and the JSTL"/>
  </target>

  <!-- Download the servlet JAR -->
  <target name="download-servlet-jar" depends="dir" 
          description="Download the servlet JAR">
    <echo message="Downloading the servlet JAR"/>
    <get src="http://www.ibiblio.org/maven/servletapi/jars/servletapi-2.4.jar"
         dest="${servlet24.jar}"
         verbose="true"/>
  </target>
  <!-- Download the JSP JAR -->
  <target name="download-jsp-jar" depends="dir" 
          description="Download the JSP JAR">
    <echo message="Downloading the JSP JAR"/>
    <get src="http://www.ibiblio.org/maven/jspapi/jars/jsp-api-2.0.jar"
         dest="${jsp20.jar}"
         verbose="true"/>
  </target>
  <!-- Building the documentation bundle        -->
  <!-- Checking that the documentation is up to date -->
  <target name="check-docs" 
          description="Check that the documentation is up to date">
    <echo message="Checking that the documentation is up to date"/>
    <condition property="docs.notRequired">
      <and>
        <uptodate targetfile="${dist}/${appName}-${package.docs}.zip">
          <srcfiles dir="${src}" includes="**"/>
        </uptodate>
        <uptodate targetfile="${dist}/${appName}-${package.docs}.tar.gz">
          <srcfiles dir="${src}" includes="**"/>
        </uptodate>
      </and>
    </condition>
  </target>  
  <!-- Generate Javadocs for the application -->
  <target name="javadocs" depends="dir,check-docs" 
          description="Generate Javadocs for the application" 
          unless="docs.notRequired">
    <echo message="Generating Javadocs for the application"/>
    <javadoc destdir="${docs}/api" windowtitle="${javadoc.windowtitle}">
      <fileset refid="javadoc"/>
      <doctitle>
        ${javadoc.doctitle}
      </doctitle>
      <classpath refid="build.classpath"/>
      <link href="http://java.sun.ru/j2se/${javadoc.j2se.version}/docs/api"/>  
      <link href="http://java.sun.ru/j2ee/${javadoc.j2ee.version}/docs/api"/> 
    </javadoc>
  </target>
   <!-- Generate Javadocs for the application, 
        using offline package-list files -->
  <target name="javadocs-offline" depends="dir,check-docs"
          description="Generate Javadocs for the application, 
                       using offline package-list files"
          unless="docs.notRequired">
    <echo message="Generating Javadocs for the application, 
                   using offline package-list files"/>
    <javadoc destdir="${docs}/api" windowtitle="${javadoc.windowtitle}">
      <fileset refid="javadoc"/>
      <doctitle>
        ${javadoc.doctitle}
      </doctitle>
      <classpath refid="build.classpath"/>
<!--
      <link href="http://java.sun.ru/j2se/${javadoc.j2se.version}/docs/api" 
            offline="true" packagelistLoc="${javadoc.j2se.offline}"/>  
      <link href="http://java.sun.ru/j2ee/${javadoc.j2ee.version}/docs/api"
            offline="true" packagelistLoc="${javadoc.j2ee.offline}"/> 
-->
      <link href="${javadoc.j2se.offline}" resolveLink="true"/>  
      <link href="${javadoc.j2ee.offline}" resolveLink="true"/> 
    </javadoc>
  </target>
  <!-- Assemble the documentation -->
  <target name="docs" depends="javadocs" 
          description="Assemble the documentation" unless="docs.notRequired">
    <echo message="Assembling the documentation"/>
    <copy todir="${docs}">
      <fileset dir="${src.shared.docs}">
        <include name="*.html"/>
      </fileset>
    </copy>
    <copy todir="${docs}/stand-alone">
      <fileset dir="${src.stand-alone.docs}">
        <include name="*.html"/>
      </fileset>
    </copy>
    <copy todir="${docs}/web">
      <fileset dir="${src.web.docs}">
        <include name="*.html"/>
      </fileset>
    </copy>
  </target>
  <!-- Zip the distribution                     -->
  <!-- Zip the documentation -->
  <target name="zip-docs" depends="docs" description="Zip the documentation">
    <echo message="Zipping the documentation"/>
    <zip destfile="${dist}/${appName}-${package.docs}.zip">
      <!-- Include the documentation -->
      <fileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </fileset>
      <!-- Include the license and the README -->
      <fileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-${package.docs}.zip" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.docs}.zip" forceOverwrite="true"  
              algorithm="SHA1"/>
  </target>
  <!-- Zip the source and documentation together -->
  <target name="zip-src" depends="zip-docs" 
          description="Zip the source and documentation together">
    <echo message="Zipping the source and documentation together"/>
    <zip destfile="${dist}/${appName}-src.zip">
      <!-- Include the source code and the build files -->
      <zipfileset src="${dist}/${appName}-${package.docs}.zip"/>
      <fileset dir="${src.files.dir}">
        <patternset refid="src.files"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-src.zip" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-src.zip" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Zip the binary stand-alone distribution with the documentation -->
  <target name="zip-bin-stand-alone" depends="package-stand-alone,zip-docs" 
          description="Zip the binary stand-alone distribution 
                       with the documentation">
    <echo message="Zipping the binary stand-alone distribution with the documentation"/>
    <zip destfile="${dist}/${appName}-${package.stand-alone}-bin.zip">
      <!-- Include the documentation -->
      <zipfileset src="${dist}/${appName}-${package.docs}.zip"/>
      <!-- Include the binary JAR files -->
      <zipfileset dir="${dist}" prefix="lib">
        <patternset refid="bin.jar"/>
      </zipfileset>
      <fileset dir=".">
        <include name="${mysql.jar}"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.zip" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.zip" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Zip the binary web distribution with the documentation -->
  <target name="zip-bin-web" depends="package-web,zip-docs" 
          description="Zip the binary web distribution with the documentation">
    <echo message="Zipping the binary web distribution with the documentation"/>
    <zip destfile="${dist}/${appName}-${package.web}-bin.zip">
      <!-- Include the documentation -->
      <zipfileset src="${dist}/${appName}-${package.docs}.zip"/>
      <!-- Include the binary WAR files -->
      <fileset dir="${dist}">
        <patternset refid="bin.war"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-${package.web}-bin.zip" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.web}-bin.zip" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Zip the binary distribution with the documentation -->
  <target name="zip-bin" depends="zip-bin-stand-alone,zip-bin-web" 
          description="Zip the binary distribution with the documentation">
    <echo message="Zipping the binary distribution with the documentation"/>
    <zip destfile="${dist}/${appName}-bin.zip" 
         duplicate="preserve" update="true">
      <zipgroupfileset dir="${dist}" includes="*.zip"/>
    </zip>
    <checksum file="${dist}/${appName}-bin.zip" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-bin.zip" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Zip the binary and source distributions -->
  <target name="zip-all" depends="zip-src,zip-bin" 
          description="Zip the binary and source distributions">
    <echo message="Zipped the binary and source distributions"/>
  </target>
  <!-- Tar and gz the distribution              -->
  <!-- Tar the documentation -->
  <target name="tar-docs" depends="docs" description="Tar the documentation">
    <echo message="Tarring the documentation"/>
    <tar destfile="${dist}/${appName}-${package.docs}.tar.gz" compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
    </tar> 
    <checksum file="${dist}/${appName}-${package.docs}.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.docs}.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the source and documentation together -->
  <target name="tar-src" depends="tar-docs"
          description="Tar the documentation">
    <echo message="Tarring the documentation"/>
    <tar destfile="${dist}/${appName}-src.tar.gz" compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the source code and the build files -->
      <tarfileset dir="${src.files.dir}">
        <patternset refid="src.files"/>
      </tarfileset>
    </tar> 
    <checksum file="${dist}/${appName}-src.tar.gz" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-src.tar.gz" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Tar the binary stand-alone distribution with the documentation -->
  <target name="tar-bin-stand-alone" depends="package-stand-alone,tar-docs" 
          description="Tar the binary stand-alone distribution 
                       with the documentation">
    <echo message="Tarring the binary stand-alone distribution with the documentation"/>
    <tar destfile="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" 
         compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the binary JAR files -->
      <tarfileset dir="${dist}" prefix="lib">
        <patternset refid="bin.jar"/>
      </tarfileset>
      <tarfileset dir=".">
        <include name="${mysql.jar}"/>
      </tarfileset>    </tar> 
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the binary web distribution with the documentation -->
  <target name="tar-bin-web" depends="package-web,tar-docs" 
          description="Tar the binary web distribution with the documentation">
    <echo message="Tarring the binary web distribution with the documentation"/>
    <tar destfile="${dist}/${appName}-${package.web}-bin.tar.gz" 
         compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the binary WAR files -->
      <tarfileset dir="${dist}">
        <patternset refid="bin.war"/>
      </tarfileset>
    </tar> 
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the binary distribution with the documentation -->
  <target name="tar-bin" depends="tar-bin-stand-alone,tar-bin-web" 
          description="Tar the binary distribution with the documentation">
    <echo message="Tarring the binary distribution with the documentation"/>
    <tar destfile="${dist}/${appName}-bin.tar.gz" compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the source code and the build files -->
      <tarfileset dir="${src.files.dir}">
        <patternset refid="src.files"/>
      </tarfileset>
      <!-- Include the binary JAR files -->
      <tarfileset dir="${dist}" prefix="lib">
        <patternset refid="bin.jar"/>
      </tarfileset>
      <tarfileset dir=".">
        <include name="${mysql.jar}"/>
      </tarfileset>
      <!-- Include the binary WAR files -->
      <tarfileset dir="${dist}">
        <patternset refid="bin.war"/>
      </tarfileset>
    </tar>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Tasks that use the zip files to construct tar files -->
  <!-- Tar the binary web distribution with the documentation -->
  <target name="tar-bin-web-new" depends="package-web,tar-docs,zip-bin-web" 
          description="Tar the binary web distribution with the documentation">
    <echo message="Tarring the binary web distribution with the documentation"/>
    <unzip src="${dist}/${appName}-${package.web}-bin.zip" dest="${tmp}/web"/>
    <tar destfile="${dist}/${appName}-${package.web}-bin.tar.gz" 
         compression="gzip">
      <tarfileset dir="${tmp}/web"/>
    </tar>
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the binary distribution with the documentation -->
  <target name="tar-bin-new" 
          depends="zip-bin,tar-bin-stand-alone,tar-bin-web-new"
          description="Tar the binary distribution with the documentation">
    <echo message="Tarring the binary distribution with the documentation"/>
    <delete failonerror="false" includeemptydirs="true">
      <fileset dir="${tmp}" includes="**"/>
    </delete>
    <unzip src="${dist}/${appName}-bin.zip" dest="${tmp}"/>
    <tar destfile="${dist}/${appName}-bin.tar.gz" compression="gzip">
      <tarfileset dir="${tmp}"/>
    </tar>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Tar the binary and source distributions -->
  <target name="tar-all" depends="tar-src,tar-bin" 
          description="Tar the binary and source distributions">
    <echo message="Tarred the binary and source distributions"/>
  </target>
  <!-- Distribution targets -->
  <!-- FTP targets         -->
  <!-- Place the documentation on FTP -->
<!--
  <target name="ftp-docs" depends="zip-docs,tar-docs" 
          description="Place the documentation on FTP">
    <echo message="Placing the documentation on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.src.dir}"
         action="send">
      <fileset dir="${dist}">
        <include name="${appName}-${package.docs}.*"/>
      </fileset>
    </ftp>
  </target>
-->
  <!-- Place the documentation on FTP -->
  <target name="ftp-docs" depends="zip-docs,tar-docs" 
          description="Place the documentation on FTP">
    <echo message="Placing the documentation on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.src.dir}"
         action="send"
         newer="true"
         timediffauto="true">
      <fileset dir="${dist}">
        <include name="${appName}-${package.docs}.*"/>
      </fileset>
    </ftp>
  </target>
  <!-- Place the source code on FTP -->
  <target name="ftp-src" depends="zip-src,tar-src" 
          description="Place the source code on FTP">
    <echo message="Placing the source code on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.src.dir}"
         action="send"
         newer="true"
         timediffauto="true">
      <fileset dir="${dist}">
        <include name="${appName}-src.*"/>
      </fileset>
    </ftp>
  </target>
  <!-- Place the binaries on FTP -->
  <target name="ftp-bin" depends="zip-bin,tar-bin" 
          description="Place the binaries on FTP">
    <echo message="Placing the binaries on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.bin.dir}"
         action="send"
         newer="true"
         timediffauto="true">
      <fileset dir="${dist}">
        <include name="${appName}*bin*"/>
      </fileset>
    </ftp>
  </target>
  <!-- Place everything on FTP -->
  <target name="ftp" description="Place everything on FTP">
    <echo message="Placing everything on FTP"/>
    <antcall target="ftp-docs"/>
    <antcall target="ftp-src"/>
    <antcall target="ftp-bin"/>
  </target>
  <!-- Place everything on FTP -->
<!--
  <target name="ftp" description="Place everything on FTP">
    <echo message="Placing everything on FTP"/>
    <input message="Please enter your username." addproperty="ftp.user"/>
    <input message="Please enter your password." addproperty="ftp.password"/>
    <splash showduration="0"/>
    <antcall target="ftp-docs"/>
    <antcall target="ftp-src"/>
    <antcall target="ftp-bin"/>
  </target>
-->
  <!-- Email targets       -->
  <!-- E-mail the documentation -->
  <target name="email-docs" depends="zip-docs,tar-docs" 
          description="E-mailing the documentation">
    <echo message="E-mailing the documentation"/>
    <mail from="${mail.from}"
          tolist="${mail.tolist}"
          mailhost="${mail.mailhost}"
          user="${mail.user}"
          password="${mail.password}"
          subject="${mail.subject}">
      <message>
        ${mail.message.docs}
      </message>
      <fileset dir="${dist}">
        <include name="${appName}-${package.docs}.*"/>
      </fileset>
    </mail>
  </target>
  <!-- Deploy the web application       -->
  <!-- 1. Copy the expanded web application -->
  <target name="deploy-copy-files" depends="copy-web" 
          description="Deploy the application by copying it to Tomcat">
    <echo message="Copying the expanded web application to CATALINA_HOME"/>
    <property environment="env"/>
    <copy todir="${build.web.web-inf}" file="${src.web.conf}/web.xml"/>
    <copy todir="${env.CATALINA_HOME}/webapps/${appName}">
      <fileset dir="${build.web.root}"/>
    </copy>
  </target>
  <!-- 2. Copy the WAR -->
  <target name="deploy-copy-war" depends="package-web" 
          description="Deploy the WAR by copying it to Tomcat">
    <echo message="Copying the WAR to CATALINA_HOME"/>
    <property environment="env"/>
    <copy file="${appName.war}" todir="${env.CATALINA_HOME}/webapps"/>
  </target>
  <!-- 3. Deploy the web application using a context XML file -->
  <target name="deploy-context" depends="copy-web" 
          description="Deploy the web application using a context XML file">
    <echo message="Deploying the web application using a context XML file"/>
    <property environment="env"/>
    <copy todir="${build.web.web-inf}" file="${src.web.conf}/web.xml"/>
    <copy todir="${env.CATALINA_HOME}/conf/Catalina/localhost" 
          file="${src.web.conf}/${appName}.xml"/>
  </target>
  <!-- The deploy task for web applications on Tomcat -->
  <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"/>
  <!-- 4. Deploy the WAR using the manager application -->
  <target name="deploy" depends="package-web" 
          description="Hot deploy the application">
    <echo message="Deploying the WAR to Tomcat"/>
    <deploy url="${manager.url}"
            username="${manager.user}"
            password="${manager.password}"  
            path="/${appName}"
            war="file:${appName.war}"
            update="true"/>
  </target>
  <!-- The undeploy task for web applications on Tomcat -->
  <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"/>
  <!-- Undeploy the web application -->
  <target name="undeploy" description="Undeploy the application">
    <echo message="Undeploying the WAR"/>
    <undeploy url="${manager.url}"
              username="${manager.user}"   
              password="${manager.password}"
              path="/${appName}"/>
  </target>
  <target name="clean" description="Clean up the working directories">
    <echo message="Cleaning up"/>
    <delete dir="${build}"/>
  </target>
</project>





Tar the binary stand-alone distribution with the documentation

 
<?xml version="1.0"?>
<project name="Example Application Build" default="build-both" basedir=".">
  
  <property file="build.properties"/>
  <!-- CVSROOT for the JSTL -->
  <property name="cvsroot" 
            value=":pserver:anoncvs@cvs.apache.org:/home/cvspublic" />
  <!-- CVSROOT for the MySQL connector -->
  <property name="mysql.cvsroot" 
            value=":pserver:anonymous@cvs.sourceforge.net:/cvsroot/mmmysql" />
  <!-- The master build classpath          --> 
  <path id="build.classpath">
    <pathelement location="${servlet24.jar}"/>
    <pathelement location="${jsp20.jar}"/>
    <pathelement location="${mysql.jar}"/>
    <pathelement path="${appName.jar}"/>
  </path>
  <!-- Javadoc file sets                   --> 
  <fileset id="javadoc" dir="${src}">
    <exclude name="*/conf/**"/>
    <exclude name="*/docs/*"/>
    <include name="shared/**"/>
    <include name="stand-alone/**"/>
    <include name="web/java/**"/>
  </fileset>  
  <!-- Properties and pattern sets for the packaging targets --> 
  <!-- The value of each property in this section is the setting -->
  <!-- for the "dir" attribute of file sets and tar file sets --> 
  <!-- Property and pattern set for the documentation -->
  <property name="docs.all.dir" value="${build}"/>
  <!-- Tar file sets cannot use file sets, so we must use a pattern set -->
  <patternset id="docs.all">
    <include name="docs/**"/>
  </patternset>
  <!-- Property and pattern set for the license and README -->
  <property name="docs.misc.dir" value="${src}/shared/docs"/>
  <!-- Tar file sets cannot use file sets, so we must use a pattern set -->
  <patternset id="docs.misc">
    <include name="README"/>
    <include name="LICENSE"/>
  </patternset>
  
  <!-- Property and pattern set for the source, -->
  <!-- build.xml, and build.properties -->
  <property name="src.files.dir" value="."/>
  <!-- Tar file sets cannot use file sets, so we must use a pattern set -->
  <patternset id="src.files">
    <include name="${src}/**"/>
    <include name="build.*"/>
  </patternset>
  <!-- Pattern set for the binary JAR -->
  <!-- Nothing else is needed because the directory that contains it -->
  <!-- is already in the ${dist} property and it"s used in a zip file set -->
  <!-- as well as a tar file set --> 
  <patternset id="bin.jar">
    <include name="*.jar"/>
  </patternset>
  <!-- Pattern set for the binary WAR -->
  <!-- Nothing else is needed because the directory that contains it -->
  <!-- is already in the ${dist} property and it"s used in a zip file set -->
  <!-- as well as a tar file set --> 
  <patternset id="bin.war">
    <include name="*.war"/>
  </patternset>
  <!-- Initialization target               --> 
  <!-- Create the working directories -->
  <target name="dir" description="Create the working directories">
    <echo message="Creating the working directories"/>
    <mkdir dir="${build.stand-alone.root}"/>
    <mkdir dir="${build.web.classes}"/>
    <mkdir dir="${dist}"/>
    <mkdir dir="${lib}"/>
  </target>
  <!-- CVS and build tasks for the JSTL and MySQL connector -->
  <!-- Update or check out required sources from CVS for the JSTL -->
  <target name="checkout-jstl" depends="dir" 
          description="Update or check out required sources
                       from CVS for the JSTL">
    <echo message="Checking out the required JSTL sources from CVS"/>
    <cvs cvsroot="${cvsroot}" quiet="true"
         command="checkout -P ${jstl.build}" 
         dest="${build}" compression="true" />
  </target>
  <!-- Update or check out required sources from CVS for the MySQL connector -->
  <target name="checkout-mysql-connector" depends="dir" 
          description="Update or check out required sources
          from CVS for the MySQL connector">
    <echo message="Checking out the required sources from CVS for the MySQL connector" />
    <cvs cvsroot="${mysql.cvsroot}" quiet="true"
         command="checkout" package="${mysql.build}"
         dest="${build}" compression="true" />
  </target>
  <!-- Build the JSTL from source -->
  <target name="build-jstl" depends="checkout-jstl" 
          description="Build the JSTL from source">
    <echo message="Building the JSTL from source"/>
    <ant antfile="build.xml" dir="${build}/${jstl.build}"/>
    <copy todir="${lib}">
      <fileset dir="${build}/${jstl.build}/${build}/lib">
        <include name="*.jar"/>
      </fileset>
    </copy>
  </target>
  <!-- Build the MySQL connector from source -->
  <target name="build-mysql-connector" depends="checkout-mysql-connector" 
          description="Build the MySQL connector from source">
    <echo message="Building the MySQL connector from source"/>
    <!-- The MySQL connector file needs this directory to exist -->
    <!-- Therefore we need to create it -->
    <mkdir dir="${build}/dist-mysql-jdbc"/>
    <ant antfile="build.xml" dir="${build}/${mysql.build}"/>
    <copy tofile="${mysql.jar}">
      <fileset dir="${build}/build-mysql-jdbc">
        <include name="mysql-connector*/*.jar"/>
      </fileset>
    </copy>
  </target>
  <!-- Compile the stand-alone application -->
  <target name="compile-stand-alone" depends="dir" 
          description="Compile stand-alone application">
    <echo message="Compiling the stand-alone application"/>
    <javac srcdir="${src.shared.java}" destdir="${build.stand-alone.root}"/>
    <javac srcdir="${src.stand-alone.java}" 
           destdir="${build.stand-alone.root}"/>  
  </target>
<!--
  <target name="stand-alone-complete" 
          description="Compile stand-alone application, 
          using CVS version of the MySQL connector">
    <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/>
    <antcall target="build-mysql-connector"/>
    <antcall target="package-stand-alone"/>
  </target>
  <target name="stand-alone-complete" 
          depends="build-mysql-connector, package-stand-alone" 
          description="Compile stand-alone application, 
          using CVS version of the MySQL connector">
    <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/>
  </target> 
-->
  <target name="stand-alone-complete" 
          depends="build-mysql-connector, package-stand-alone" 
          description="Compile stand-alone application, 
                       using CVS version of the MySQL connector">
    <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/>
  </target>
  <!-- Package the stand-alone application -->
  <target name="package-stand-alone" depends="compile-stand-alone" 
          description="Package the stand-alone application">
    <echo message="Creating the stand-alone JAR file"/>
    <copy file="${database.properties}" todir="${build.stand-alone.root}"/>
    <jar destfile="${appName.jar}" basedir="${build.stand-alone.root}"/>
  </target>
  <!-- Compile the web application -->
  <target name="compile-web" depends="dir" description="Compile web application">
    <echo message="Compiling the web application"/>
    <javac destdir="${build.web.classes}">
      <src path="${src.shared.java}"/>
    </javac>
    <javac srcdir="${src.web.java}" destdir="${build.web.classes}">
      <classpath refid="build.classpath"/>
    </javac>
  </target>
<!--
  <target name="web-complete" 
          description="Compile web application, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling web application, using CVS versions of the MySQL connector and the JSTL"/>
    <antcall target="build-mysql-connector"/>
    <antcall target="build-jstl"/>
    <antcall target="package-web"/>
  </target>
  <target name="web-complete" 
          depends="build-mysql-connector, build-jstl, package-web" 
          description="Compile web application, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiled web application, using CVS versions of the MySQL connector and the JSTL"/>
  </target>
-->
  <target name="web-complete" 
          depends="build-mysql-connector, build-jstl, package-web" 
          description="Compile web application, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling web application, using CVS versions of the MySQL connector and the JSTL"/>
  </target>
  <!-- Copy the web pages and configuration files -->
  <target name="copy-web" depends="compile-web" description="Copy the web files">
    <echo message="Copying the web pages and configuration files"/>
    <copy todir="${build.web.root}">
      <fileset dir="${src.web.pages}"/>
    </copy>
    <!-- Copy the tags -->
    <copy todir="${build.web.tags}">
      <fileset dir="${src.web.tags}"/>
    </copy>
    <copy todir="${build.web.web-inf}">
      <fileset dir="${src.web.conf}">
        <include name="*.tld"/>
      </fileset>
    </copy>
    <!-- Copy the JAR files -->
    <copy todir="${build.web.lib}">
      <fileset dir="${lib}"/>
    </copy>
    <!-- Copy the properties file -->
    <copy file="${database.properties}" todir="${build.web.classes}"/>
    <!-- No need to copy web.xml, as the WAR task does this for us -->
  </target>
  <!-- Build the WAR file -->
<!--
  <target name="package-web" depends="copy-web" description="Build the WAR">
    <echo message="Building the WAR file"/> 
    <war destfile="${appName.war}" basedir="${build.web.root}" 
         webxml="${src.web.conf}/web.xml"/>
  </target>
-->
  <!-- Build the WAR file in one step -->
  <target name="package-web" depends="compile-web" 
          description="Build the WAR file in one step">
    <echo message="Building the WAR file in one step"/> 
    <war destfile="${appName.war}" basedir="${src.web.pages}" 
         webxml="${src.web.conf}/web.xml">
      <lib dir="${lib}"/>
      <classes dir="${build.web.root}"/>
      <zipfileset dir="${src.web.tags}" prefix="WEB-INF/tags"/>
      <zipfileset file="${database.properties}" prefix="WEB-INF/classes"/>
      <zipfileset dir="${src.web.conf}" prefix="WEB-INF">
        <include name="*.tld"/>
      </zipfileset>
    </war>
  </target>
  <!-- Targets that work with both applications -->
<!--
  <target name="build-both" 
          description="Compile both applications, 
                       without CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling both applications, without CVS versions of the MySQL connector and the JSTL"/>
    <antcall target="package-stand-alone"/>
    <antcall target="package-web"/>
  </target>
  <target name="build-all" 
          description="Compile both applications, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling both applications, using CVS versions of the MySQL connector and the JSTL"/>
    <antcall target="stand-alone-complete"/>
    <antcall target="web-complete"/>
  </target>
-->
  <target name="build-both" 
          depends="package-stand-alone, package-web" 
          description="Compile both applications, 
                       without CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiled both applications, without CVS versions of the MySQL connector and the JSTL"/>
  </target>
  <target name="build-all" 
          depends="stand-alone-complete, web-complete" 
          description="Compile both applications, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiled both applications, using CVS versions of the MySQL connector and the JSTL"/>
  </target>

  <!-- Download the servlet JAR -->
  <target name="download-servlet-jar" depends="dir" 
          description="Download the servlet JAR">
    <echo message="Downloading the servlet JAR"/>
    <get src="http://www.ibiblio.org/maven/servletapi/jars/servletapi-2.4.jar"
         dest="${servlet24.jar}"
         verbose="true"/>
  </target>
  <!-- Download the JSP JAR -->
  <target name="download-jsp-jar" depends="dir" 
          description="Download the JSP JAR">
    <echo message="Downloading the JSP JAR"/>
    <get src="http://www.ibiblio.org/maven/jspapi/jars/jsp-api-2.0.jar"
         dest="${jsp20.jar}"
         verbose="true"/>
  </target>
  <!-- Building the documentation bundle        -->
  <!-- Checking that the documentation is up to date -->
  <target name="check-docs" 
          description="Check that the documentation is up to date">
    <echo message="Checking that the documentation is up to date"/>
    <condition property="docs.notRequired">
      <and>
        <uptodate targetfile="${dist}/${appName}-${package.docs}.zip">
          <srcfiles dir="${src}" includes="**"/>
        </uptodate>
        <uptodate targetfile="${dist}/${appName}-${package.docs}.tar.gz">
          <srcfiles dir="${src}" includes="**"/>
        </uptodate>
      </and>
    </condition>
  </target>  
  <!-- Generate Javadocs for the application -->
  <target name="javadocs" depends="dir,check-docs" 
          description="Generate Javadocs for the application" 
          unless="docs.notRequired">
    <echo message="Generating Javadocs for the application"/>
    <javadoc destdir="${docs}/api" windowtitle="${javadoc.windowtitle}">
      <fileset refid="javadoc"/>
      <doctitle>
        ${javadoc.doctitle}
      </doctitle>
      <classpath refid="build.classpath"/>
      <link href="http://java.sun.ru/j2se/${javadoc.j2se.version}/docs/api"/>  
      <link href="http://java.sun.ru/j2ee/${javadoc.j2ee.version}/docs/api"/> 
    </javadoc>
  </target>
   <!-- Generate Javadocs for the application, 
        using offline package-list files -->
  <target name="javadocs-offline" depends="dir,check-docs"
          description="Generate Javadocs for the application, 
                       using offline package-list files"
          unless="docs.notRequired">
    <echo message="Generating Javadocs for the application, 
                   using offline package-list files"/>
    <javadoc destdir="${docs}/api" windowtitle="${javadoc.windowtitle}">
      <fileset refid="javadoc"/>
      <doctitle>
        ${javadoc.doctitle}
      </doctitle>
      <classpath refid="build.classpath"/>
<!--
      <link href="http://java.sun.ru/j2se/${javadoc.j2se.version}/docs/api" 
            offline="true" packagelistLoc="${javadoc.j2se.offline}"/>  
      <link href="http://java.sun.ru/j2ee/${javadoc.j2ee.version}/docs/api"
            offline="true" packagelistLoc="${javadoc.j2ee.offline}"/> 
-->
      <link href="${javadoc.j2se.offline}" resolveLink="true"/>  
      <link href="${javadoc.j2ee.offline}" resolveLink="true"/> 
    </javadoc>
  </target>
  <!-- Assemble the documentation -->
  <target name="docs" depends="javadocs" 
          description="Assemble the documentation" unless="docs.notRequired">
    <echo message="Assembling the documentation"/>
    <copy todir="${docs}">
      <fileset dir="${src.shared.docs}">
        <include name="*.html"/>
      </fileset>
    </copy>
    <copy todir="${docs}/stand-alone">
      <fileset dir="${src.stand-alone.docs}">
        <include name="*.html"/>
      </fileset>
    </copy>
    <copy todir="${docs}/web">
      <fileset dir="${src.web.docs}">
        <include name="*.html"/>
      </fileset>
    </copy>
  </target>
  <!-- Zip the distribution                     -->
  <!-- Zip the documentation -->
  <target name="zip-docs" depends="docs" description="Zip the documentation">
    <echo message="Zipping the documentation"/>
    <zip destfile="${dist}/${appName}-${package.docs}.zip">
      <!-- Include the documentation -->
      <fileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </fileset>
      <!-- Include the license and the README -->
      <fileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-${package.docs}.zip" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.docs}.zip" forceOverwrite="true"  
              algorithm="SHA1"/>
  </target>
  <!-- Zip the source and documentation together -->
  <target name="zip-src" depends="zip-docs" 
          description="Zip the source and documentation together">
    <echo message="Zipping the source and documentation together"/>
    <zip destfile="${dist}/${appName}-src.zip">
      <!-- Include the source code and the build files -->
      <zipfileset src="${dist}/${appName}-${package.docs}.zip"/>
      <fileset dir="${src.files.dir}">
        <patternset refid="src.files"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-src.zip" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-src.zip" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Zip the binary stand-alone distribution with the documentation -->
  <target name="zip-bin-stand-alone" depends="package-stand-alone,zip-docs" 
          description="Zip the binary stand-alone distribution 
                       with the documentation">
    <echo message="Zipping the binary stand-alone distribution with the documentation"/>
    <zip destfile="${dist}/${appName}-${package.stand-alone}-bin.zip">
      <!-- Include the documentation -->
      <zipfileset src="${dist}/${appName}-${package.docs}.zip"/>
      <!-- Include the binary JAR files -->
      <zipfileset dir="${dist}" prefix="lib">
        <patternset refid="bin.jar"/>
      </zipfileset>
      <fileset dir=".">
        <include name="${mysql.jar}"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.zip" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.zip" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Zip the binary web distribution with the documentation -->
  <target name="zip-bin-web" depends="package-web,zip-docs" 
          description="Zip the binary web distribution with the documentation">
    <echo message="Zipping the binary web distribution with the documentation"/>
    <zip destfile="${dist}/${appName}-${package.web}-bin.zip">
      <!-- Include the documentation -->
      <zipfileset src="${dist}/${appName}-${package.docs}.zip"/>
      <!-- Include the binary WAR files -->
      <fileset dir="${dist}">
        <patternset refid="bin.war"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-${package.web}-bin.zip" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.web}-bin.zip" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Zip the binary distribution with the documentation -->
  <target name="zip-bin" depends="zip-bin-stand-alone,zip-bin-web" 
          description="Zip the binary distribution with the documentation">
    <echo message="Zipping the binary distribution with the documentation"/>
    <zip destfile="${dist}/${appName}-bin.zip" 
         duplicate="preserve" update="true">
      <zipgroupfileset dir="${dist}" includes="*.zip"/>
    </zip>
    <checksum file="${dist}/${appName}-bin.zip" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-bin.zip" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Zip the binary and source distributions -->
  <target name="zip-all" depends="zip-src,zip-bin" 
          description="Zip the binary and source distributions">
    <echo message="Zipped the binary and source distributions"/>
  </target>
  <!-- Tar and gz the distribution              -->
  <!-- Tar the documentation -->
  <target name="tar-docs" depends="docs" description="Tar the documentation">
    <echo message="Tarring the documentation"/>
    <tar destfile="${dist}/${appName}-${package.docs}.tar.gz" compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
    </tar> 
    <checksum file="${dist}/${appName}-${package.docs}.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.docs}.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the source and documentation together -->
  <target name="tar-src" depends="tar-docs"
          description="Tar the documentation">
    <echo message="Tarring the documentation"/>
    <tar destfile="${dist}/${appName}-src.tar.gz" compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the source code and the build files -->
      <tarfileset dir="${src.files.dir}">
        <patternset refid="src.files"/>
      </tarfileset>
    </tar> 
    <checksum file="${dist}/${appName}-src.tar.gz" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-src.tar.gz" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Tar the binary stand-alone distribution with the documentation -->
  <target name="tar-bin-stand-alone" depends="package-stand-alone,tar-docs" 
          description="Tar the binary stand-alone distribution 
                       with the documentation">
    <echo message="Tarring the binary stand-alone distribution with the documentation"/>
    <tar destfile="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" 
         compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the binary JAR files -->
      <tarfileset dir="${dist}" prefix="lib">
        <patternset refid="bin.jar"/>
      </tarfileset>
      <tarfileset dir=".">
        <include name="${mysql.jar}"/>
      </tarfileset>    </tar> 
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the binary web distribution with the documentation -->
  <target name="tar-bin-web" depends="package-web,tar-docs" 
          description="Tar the binary web distribution with the documentation">
    <echo message="Tarring the binary web distribution with the documentation"/>
    <tar destfile="${dist}/${appName}-${package.web}-bin.tar.gz" 
         compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the binary WAR files -->
      <tarfileset dir="${dist}">
        <patternset refid="bin.war"/>
      </tarfileset>
    </tar> 
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the binary distribution with the documentation -->
  <target name="tar-bin" depends="tar-bin-stand-alone,tar-bin-web" 
          description="Tar the binary distribution with the documentation">
    <echo message="Tarring the binary distribution with the documentation"/>
    <tar destfile="${dist}/${appName}-bin.tar.gz" compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the source code and the build files -->
      <tarfileset dir="${src.files.dir}">
        <patternset refid="src.files"/>
      </tarfileset>
      <!-- Include the binary JAR files -->
      <tarfileset dir="${dist}" prefix="lib">
        <patternset refid="bin.jar"/>
      </tarfileset>
      <tarfileset dir=".">
        <include name="${mysql.jar}"/>
      </tarfileset>
      <!-- Include the binary WAR files -->
      <tarfileset dir="${dist}">
        <patternset refid="bin.war"/>
      </tarfileset>
    </tar>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Tasks that use the zip files to construct tar files -->
  <!-- Tar the binary web distribution with the documentation -->
  <target name="tar-bin-web-new" depends="package-web,tar-docs,zip-bin-web" 
          description="Tar the binary web distribution with the documentation">
    <echo message="Tarring the binary web distribution with the documentation"/>
    <unzip src="${dist}/${appName}-${package.web}-bin.zip" dest="${tmp}/web"/>
    <tar destfile="${dist}/${appName}-${package.web}-bin.tar.gz" 
         compression="gzip">
      <tarfileset dir="${tmp}/web"/>
    </tar>
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the binary distribution with the documentation -->
  <target name="tar-bin-new" 
          depends="zip-bin,tar-bin-stand-alone,tar-bin-web-new"
          description="Tar the binary distribution with the documentation">
    <echo message="Tarring the binary distribution with the documentation"/>
    <delete failonerror="false" includeemptydirs="true">
      <fileset dir="${tmp}" includes="**"/>
    </delete>
    <unzip src="${dist}/${appName}-bin.zip" dest="${tmp}"/>
    <tar destfile="${dist}/${appName}-bin.tar.gz" compression="gzip">
      <tarfileset dir="${tmp}"/>
    </tar>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Tar the binary and source distributions -->
  <target name="tar-all" depends="tar-src,tar-bin" 
          description="Tar the binary and source distributions">
    <echo message="Tarred the binary and source distributions"/>
  </target>
  <!-- Distribution targets -->
  <!-- FTP targets         -->
  <!-- Place the documentation on FTP -->
<!--
  <target name="ftp-docs" depends="zip-docs,tar-docs" 
          description="Place the documentation on FTP">
    <echo message="Placing the documentation on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.src.dir}"
         action="send">
      <fileset dir="${dist}">
        <include name="${appName}-${package.docs}.*"/>
      </fileset>
    </ftp>
  </target>
-->
  <!-- Place the documentation on FTP -->
  <target name="ftp-docs" depends="zip-docs,tar-docs" 
          description="Place the documentation on FTP">
    <echo message="Placing the documentation on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.src.dir}"
         action="send"
         newer="true"
         timediffauto="true">
      <fileset dir="${dist}">
        <include name="${appName}-${package.docs}.*"/>
      </fileset>
    </ftp>
  </target>
  <!-- Place the source code on FTP -->
  <target name="ftp-src" depends="zip-src,tar-src" 
          description="Place the source code on FTP">
    <echo message="Placing the source code on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.src.dir}"
         action="send"
         newer="true"
         timediffauto="true">
      <fileset dir="${dist}">
        <include name="${appName}-src.*"/>
      </fileset>
    </ftp>
  </target>
  <!-- Place the binaries on FTP -->
  <target name="ftp-bin" depends="zip-bin,tar-bin" 
          description="Place the binaries on FTP">
    <echo message="Placing the binaries on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.bin.dir}"
         action="send"
         newer="true"
         timediffauto="true">
      <fileset dir="${dist}">
        <include name="${appName}*bin*"/>
      </fileset>
    </ftp>
  </target>
  <!-- Place everything on FTP -->
  <target name="ftp" description="Place everything on FTP">
    <echo message="Placing everything on FTP"/>
    <antcall target="ftp-docs"/>
    <antcall target="ftp-src"/>
    <antcall target="ftp-bin"/>
  </target>
  <!-- Place everything on FTP -->
<!--
  <target name="ftp" description="Place everything on FTP">
    <echo message="Placing everything on FTP"/>
    <input message="Please enter your username." addproperty="ftp.user"/>
    <input message="Please enter your password." addproperty="ftp.password"/>
    <splash showduration="0"/>
    <antcall target="ftp-docs"/>
    <antcall target="ftp-src"/>
    <antcall target="ftp-bin"/>
  </target>
-->
  <!-- Email targets       -->
  <!-- E-mail the documentation -->
  <target name="email-docs" depends="zip-docs,tar-docs" 
          description="E-mailing the documentation">
    <echo message="E-mailing the documentation"/>
    <mail from="${mail.from}"
          tolist="${mail.tolist}"
          mailhost="${mail.mailhost}"
          user="${mail.user}"
          password="${mail.password}"
          subject="${mail.subject}">
      <message>
        ${mail.message.docs}
      </message>
      <fileset dir="${dist}">
        <include name="${appName}-${package.docs}.*"/>
      </fileset>
    </mail>
  </target>
  <!-- Deploy the web application       -->
  <!-- 1. Copy the expanded web application -->
  <target name="deploy-copy-files" depends="copy-web" 
          description="Deploy the application by copying it to Tomcat">
    <echo message="Copying the expanded web application to CATALINA_HOME"/>
    <property environment="env"/>
    <copy todir="${build.web.web-inf}" file="${src.web.conf}/web.xml"/>
    <copy todir="${env.CATALINA_HOME}/webapps/${appName}">
      <fileset dir="${build.web.root}"/>
    </copy>
  </target>
  <!-- 2. Copy the WAR -->
  <target name="deploy-copy-war" depends="package-web" 
          description="Deploy the WAR by copying it to Tomcat">
    <echo message="Copying the WAR to CATALINA_HOME"/>
    <property environment="env"/>
    <copy file="${appName.war}" todir="${env.CATALINA_HOME}/webapps"/>
  </target>
  <!-- 3. Deploy the web application using a context XML file -->
  <target name="deploy-context" depends="copy-web" 
          description="Deploy the web application using a context XML file">
    <echo message="Deploying the web application using a context XML file"/>
    <property environment="env"/>
    <copy todir="${build.web.web-inf}" file="${src.web.conf}/web.xml"/>
    <copy todir="${env.CATALINA_HOME}/conf/Catalina/localhost" 
          file="${src.web.conf}/${appName}.xml"/>
  </target>
  <!-- The deploy task for web applications on Tomcat -->
  <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"/>
  <!-- 4. Deploy the WAR using the manager application -->
  <target name="deploy" depends="package-web" 
          description="Hot deploy the application">
    <echo message="Deploying the WAR to Tomcat"/>
    <deploy url="${manager.url}"
            username="${manager.user}"
            password="${manager.password}"  
            path="/${appName}"
            war="file:${appName.war}"
            update="true"/>
  </target>
  <!-- The undeploy task for web applications on Tomcat -->
  <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"/>
  <!-- Undeploy the web application -->
  <target name="undeploy" description="Undeploy the application">
    <echo message="Undeploying the WAR"/>
    <undeploy url="${manager.url}"
              username="${manager.user}"   
              password="${manager.password}"
              path="/${appName}"/>
  </target>
  <target name="clean" description="Clean up the working directories">
    <echo message="Cleaning up"/>
    <delete dir="${build}"/>
  </target>
</project>





Tar the binary web distribution with the documentation

 
<?xml version="1.0"?>
<project name="Example Application Build" default="build-both" basedir=".">
  
  <property file="build.properties"/>
  <!-- CVSROOT for the JSTL -->
  <property name="cvsroot" 
            value=":pserver:anoncvs@cvs.apache.org:/home/cvspublic" />
  <!-- CVSROOT for the MySQL connector -->
  <property name="mysql.cvsroot" 
            value=":pserver:anonymous@cvs.sourceforge.net:/cvsroot/mmmysql" />
  <!-- The master build classpath          --> 
  <path id="build.classpath">
    <pathelement location="${servlet24.jar}"/>
    <pathelement location="${jsp20.jar}"/>
    <pathelement location="${mysql.jar}"/>
    <pathelement path="${appName.jar}"/>
  </path>
  <!-- Javadoc file sets                   --> 
  <fileset id="javadoc" dir="${src}">
    <exclude name="*/conf/**"/>
    <exclude name="*/docs/*"/>
    <include name="shared/**"/>
    <include name="stand-alone/**"/>
    <include name="web/java/**"/>
  </fileset>  
  <!-- Properties and pattern sets for the packaging targets --> 
  <!-- The value of each property in this section is the setting -->
  <!-- for the "dir" attribute of file sets and tar file sets --> 
  <!-- Property and pattern set for the documentation -->
  <property name="docs.all.dir" value="${build}"/>
  <!-- Tar file sets cannot use file sets, so we must use a pattern set -->
  <patternset id="docs.all">
    <include name="docs/**"/>
  </patternset>
  <!-- Property and pattern set for the license and README -->
  <property name="docs.misc.dir" value="${src}/shared/docs"/>
  <!-- Tar file sets cannot use file sets, so we must use a pattern set -->
  <patternset id="docs.misc">
    <include name="README"/>
    <include name="LICENSE"/>
  </patternset>
  
  <!-- Property and pattern set for the source, -->
  <!-- build.xml, and build.properties -->
  <property name="src.files.dir" value="."/>
  <!-- Tar file sets cannot use file sets, so we must use a pattern set -->
  <patternset id="src.files">
    <include name="${src}/**"/>
    <include name="build.*"/>
  </patternset>
  <!-- Pattern set for the binary JAR -->
  <!-- Nothing else is needed because the directory that contains it -->
  <!-- is already in the ${dist} property and it"s used in a zip file set -->
  <!-- as well as a tar file set --> 
  <patternset id="bin.jar">
    <include name="*.jar"/>
  </patternset>
  <!-- Pattern set for the binary WAR -->
  <!-- Nothing else is needed because the directory that contains it -->
  <!-- is already in the ${dist} property and it"s used in a zip file set -->
  <!-- as well as a tar file set --> 
  <patternset id="bin.war">
    <include name="*.war"/>
  </patternset>
  <!-- Initialization target               --> 
  <!-- Create the working directories -->
  <target name="dir" description="Create the working directories">
    <echo message="Creating the working directories"/>
    <mkdir dir="${build.stand-alone.root}"/>
    <mkdir dir="${build.web.classes}"/>
    <mkdir dir="${dist}"/>
    <mkdir dir="${lib}"/>
  </target>
  <!-- CVS and build tasks for the JSTL and MySQL connector -->
  <!-- Update or check out required sources from CVS for the JSTL -->
  <target name="checkout-jstl" depends="dir" 
          description="Update or check out required sources
                       from CVS for the JSTL">
    <echo message="Checking out the required JSTL sources from CVS"/>
    <cvs cvsroot="${cvsroot}" quiet="true"
         command="checkout -P ${jstl.build}" 
         dest="${build}" compression="true" />
  </target>
  <!-- Update or check out required sources from CVS for the MySQL connector -->
  <target name="checkout-mysql-connector" depends="dir" 
          description="Update or check out required sources
          from CVS for the MySQL connector">
    <echo message="Checking out the required sources from CVS for the MySQL connector" />
    <cvs cvsroot="${mysql.cvsroot}" quiet="true"
         command="checkout" package="${mysql.build}"
         dest="${build}" compression="true" />
  </target>
  <!-- Build the JSTL from source -->
  <target name="build-jstl" depends="checkout-jstl" 
          description="Build the JSTL from source">
    <echo message="Building the JSTL from source"/>
    <ant antfile="build.xml" dir="${build}/${jstl.build}"/>
    <copy todir="${lib}">
      <fileset dir="${build}/${jstl.build}/${build}/lib">
        <include name="*.jar"/>
      </fileset>
    </copy>
  </target>
  <!-- Build the MySQL connector from source -->
  <target name="build-mysql-connector" depends="checkout-mysql-connector" 
          description="Build the MySQL connector from source">
    <echo message="Building the MySQL connector from source"/>
    <!-- The MySQL connector file needs this directory to exist -->
    <!-- Therefore we need to create it -->
    <mkdir dir="${build}/dist-mysql-jdbc"/>
    <ant antfile="build.xml" dir="${build}/${mysql.build}"/>
    <copy tofile="${mysql.jar}">
      <fileset dir="${build}/build-mysql-jdbc">
        <include name="mysql-connector*/*.jar"/>
      </fileset>
    </copy>
  </target>
  <!-- Compile the stand-alone application -->
  <target name="compile-stand-alone" depends="dir" 
          description="Compile stand-alone application">
    <echo message="Compiling the stand-alone application"/>
    <javac srcdir="${src.shared.java}" destdir="${build.stand-alone.root}"/>
    <javac srcdir="${src.stand-alone.java}" 
           destdir="${build.stand-alone.root}"/>  
  </target>
<!--
  <target name="stand-alone-complete" 
          description="Compile stand-alone application, 
          using CVS version of the MySQL connector">
    <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/>
    <antcall target="build-mysql-connector"/>
    <antcall target="package-stand-alone"/>
  </target>
  <target name="stand-alone-complete" 
          depends="build-mysql-connector, package-stand-alone" 
          description="Compile stand-alone application, 
          using CVS version of the MySQL connector">
    <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/>
  </target> 
-->
  <target name="stand-alone-complete" 
          depends="build-mysql-connector, package-stand-alone" 
          description="Compile stand-alone application, 
                       using CVS version of the MySQL connector">
    <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/>
  </target>
  <!-- Package the stand-alone application -->
  <target name="package-stand-alone" depends="compile-stand-alone" 
          description="Package the stand-alone application">
    <echo message="Creating the stand-alone JAR file"/>
    <copy file="${database.properties}" todir="${build.stand-alone.root}"/>
    <jar destfile="${appName.jar}" basedir="${build.stand-alone.root}"/>
  </target>
  <!-- Compile the web application -->
  <target name="compile-web" depends="dir" description="Compile web application">
    <echo message="Compiling the web application"/>
    <javac destdir="${build.web.classes}">
      <src path="${src.shared.java}"/>
    </javac>
    <javac srcdir="${src.web.java}" destdir="${build.web.classes}">
      <classpath refid="build.classpath"/>
    </javac>
  </target>
<!--
  <target name="web-complete" 
          description="Compile web application, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling web application, using CVS versions of the MySQL connector and the JSTL"/>
    <antcall target="build-mysql-connector"/>
    <antcall target="build-jstl"/>
    <antcall target="package-web"/>
  </target>
  <target name="web-complete" 
          depends="build-mysql-connector, build-jstl, package-web" 
          description="Compile web application, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiled web application, using CVS versions of the MySQL connector and the JSTL"/>
  </target>
-->
  <target name="web-complete" 
          depends="build-mysql-connector, build-jstl, package-web" 
          description="Compile web application, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling web application, using CVS versions of the MySQL connector and the JSTL"/>
  </target>
  <!-- Copy the web pages and configuration files -->
  <target name="copy-web" depends="compile-web" description="Copy the web files">
    <echo message="Copying the web pages and configuration files"/>
    <copy todir="${build.web.root}">
      <fileset dir="${src.web.pages}"/>
    </copy>
    <!-- Copy the tags -->
    <copy todir="${build.web.tags}">
      <fileset dir="${src.web.tags}"/>
    </copy>
    <copy todir="${build.web.web-inf}">
      <fileset dir="${src.web.conf}">
        <include name="*.tld"/>
      </fileset>
    </copy>
    <!-- Copy the JAR files -->
    <copy todir="${build.web.lib}">
      <fileset dir="${lib}"/>
    </copy>
    <!-- Copy the properties file -->
    <copy file="${database.properties}" todir="${build.web.classes}"/>
    <!-- No need to copy web.xml, as the WAR task does this for us -->
  </target>
  <!-- Build the WAR file -->
<!--
  <target name="package-web" depends="copy-web" description="Build the WAR">
    <echo message="Building the WAR file"/> 
    <war destfile="${appName.war}" basedir="${build.web.root}" 
         webxml="${src.web.conf}/web.xml"/>
  </target>
-->
  <!-- Build the WAR file in one step -->
  <target name="package-web" depends="compile-web" 
          description="Build the WAR file in one step">
    <echo message="Building the WAR file in one step"/> 
    <war destfile="${appName.war}" basedir="${src.web.pages}" 
         webxml="${src.web.conf}/web.xml">
      <lib dir="${lib}"/>
      <classes dir="${build.web.root}"/>
      <zipfileset dir="${src.web.tags}" prefix="WEB-INF/tags"/>
      <zipfileset file="${database.properties}" prefix="WEB-INF/classes"/>
      <zipfileset dir="${src.web.conf}" prefix="WEB-INF">
        <include name="*.tld"/>
      </zipfileset>
    </war>
  </target>
  <!-- Targets that work with both applications -->
<!--
  <target name="build-both" 
          description="Compile both applications, 
                       without CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling both applications, without CVS versions of the MySQL connector and the JSTL"/>
    <antcall target="package-stand-alone"/>
    <antcall target="package-web"/>
  </target>
  <target name="build-all" 
          description="Compile both applications, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling both applications, using CVS versions of the MySQL connector and the JSTL"/>
    <antcall target="stand-alone-complete"/>
    <antcall target="web-complete"/>
  </target>
-->
  <target name="build-both" 
          depends="package-stand-alone, package-web" 
          description="Compile both applications, 
                       without CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiled both applications, without CVS versions of the MySQL connector and the JSTL"/>
  </target>
  <target name="build-all" 
          depends="stand-alone-complete, web-complete" 
          description="Compile both applications, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiled both applications, using CVS versions of the MySQL connector and the JSTL"/>
  </target>

  <!-- Download the servlet JAR -->
  <target name="download-servlet-jar" depends="dir" 
          description="Download the servlet JAR">
    <echo message="Downloading the servlet JAR"/>
    <get src="http://www.ibiblio.org/maven/servletapi/jars/servletapi-2.4.jar"
         dest="${servlet24.jar}"
         verbose="true"/>
  </target>
  <!-- Download the JSP JAR -->
  <target name="download-jsp-jar" depends="dir" 
          description="Download the JSP JAR">
    <echo message="Downloading the JSP JAR"/>
    <get src="http://www.ibiblio.org/maven/jspapi/jars/jsp-api-2.0.jar"
         dest="${jsp20.jar}"
         verbose="true"/>
  </target>
  <!-- Building the documentation bundle        -->
  <!-- Checking that the documentation is up to date -->
  <target name="check-docs" 
          description="Check that the documentation is up to date">
    <echo message="Checking that the documentation is up to date"/>
    <condition property="docs.notRequired">
      <and>
        <uptodate targetfile="${dist}/${appName}-${package.docs}.zip">
          <srcfiles dir="${src}" includes="**"/>
        </uptodate>
        <uptodate targetfile="${dist}/${appName}-${package.docs}.tar.gz">
          <srcfiles dir="${src}" includes="**"/>
        </uptodate>
      </and>
    </condition>
  </target>  
  <!-- Generate Javadocs for the application -->
  <target name="javadocs" depends="dir,check-docs" 
          description="Generate Javadocs for the application" 
          unless="docs.notRequired">
    <echo message="Generating Javadocs for the application"/>
    <javadoc destdir="${docs}/api" windowtitle="${javadoc.windowtitle}">
      <fileset refid="javadoc"/>
      <doctitle>
        ${javadoc.doctitle}
      </doctitle>
      <classpath refid="build.classpath"/>
      <link href="http://java.sun.ru/j2se/${javadoc.j2se.version}/docs/api"/>  
      <link href="http://java.sun.ru/j2ee/${javadoc.j2ee.version}/docs/api"/> 
    </javadoc>
  </target>
   <!-- Generate Javadocs for the application, 
        using offline package-list files -->
  <target name="javadocs-offline" depends="dir,check-docs"
          description="Generate Javadocs for the application, 
                       using offline package-list files"
          unless="docs.notRequired">
    <echo message="Generating Javadocs for the application, 
                   using offline package-list files"/>
    <javadoc destdir="${docs}/api" windowtitle="${javadoc.windowtitle}">
      <fileset refid="javadoc"/>
      <doctitle>
        ${javadoc.doctitle}
      </doctitle>
      <classpath refid="build.classpath"/>
<!--
      <link href="http://java.sun.ru/j2se/${javadoc.j2se.version}/docs/api" 
            offline="true" packagelistLoc="${javadoc.j2se.offline}"/>  
      <link href="http://java.sun.ru/j2ee/${javadoc.j2ee.version}/docs/api"
            offline="true" packagelistLoc="${javadoc.j2ee.offline}"/> 
-->
      <link href="${javadoc.j2se.offline}" resolveLink="true"/>  
      <link href="${javadoc.j2ee.offline}" resolveLink="true"/> 
    </javadoc>
  </target>
  <!-- Assemble the documentation -->
  <target name="docs" depends="javadocs" 
          description="Assemble the documentation" unless="docs.notRequired">
    <echo message="Assembling the documentation"/>
    <copy todir="${docs}">
      <fileset dir="${src.shared.docs}">
        <include name="*.html"/>
      </fileset>
    </copy>
    <copy todir="${docs}/stand-alone">
      <fileset dir="${src.stand-alone.docs}">
        <include name="*.html"/>
      </fileset>
    </copy>
    <copy todir="${docs}/web">
      <fileset dir="${src.web.docs}">
        <include name="*.html"/>
      </fileset>
    </copy>
  </target>
  <!-- Zip the distribution                     -->
  <!-- Zip the documentation -->
  <target name="zip-docs" depends="docs" description="Zip the documentation">
    <echo message="Zipping the documentation"/>
    <zip destfile="${dist}/${appName}-${package.docs}.zip">
      <!-- Include the documentation -->
      <fileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </fileset>
      <!-- Include the license and the README -->
      <fileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-${package.docs}.zip" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.docs}.zip" forceOverwrite="true"  
              algorithm="SHA1"/>
  </target>
  <!-- Zip the source and documentation together -->
  <target name="zip-src" depends="zip-docs" 
          description="Zip the source and documentation together">
    <echo message="Zipping the source and documentation together"/>
    <zip destfile="${dist}/${appName}-src.zip">
      <!-- Include the source code and the build files -->
      <zipfileset src="${dist}/${appName}-${package.docs}.zip"/>
      <fileset dir="${src.files.dir}">
        <patternset refid="src.files"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-src.zip" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-src.zip" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Zip the binary stand-alone distribution with the documentation -->
  <target name="zip-bin-stand-alone" depends="package-stand-alone,zip-docs" 
          description="Zip the binary stand-alone distribution 
                       with the documentation">
    <echo message="Zipping the binary stand-alone distribution with the documentation"/>
    <zip destfile="${dist}/${appName}-${package.stand-alone}-bin.zip">
      <!-- Include the documentation -->
      <zipfileset src="${dist}/${appName}-${package.docs}.zip"/>
      <!-- Include the binary JAR files -->
      <zipfileset dir="${dist}" prefix="lib">
        <patternset refid="bin.jar"/>
      </zipfileset>
      <fileset dir=".">
        <include name="${mysql.jar}"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.zip" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.zip" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Zip the binary web distribution with the documentation -->
  <target name="zip-bin-web" depends="package-web,zip-docs" 
          description="Zip the binary web distribution with the documentation">
    <echo message="Zipping the binary web distribution with the documentation"/>
    <zip destfile="${dist}/${appName}-${package.web}-bin.zip">
      <!-- Include the documentation -->
      <zipfileset src="${dist}/${appName}-${package.docs}.zip"/>
      <!-- Include the binary WAR files -->
      <fileset dir="${dist}">
        <patternset refid="bin.war"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-${package.web}-bin.zip" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.web}-bin.zip" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Zip the binary distribution with the documentation -->
  <target name="zip-bin" depends="zip-bin-stand-alone,zip-bin-web" 
          description="Zip the binary distribution with the documentation">
    <echo message="Zipping the binary distribution with the documentation"/>
    <zip destfile="${dist}/${appName}-bin.zip" 
         duplicate="preserve" update="true">
      <zipgroupfileset dir="${dist}" includes="*.zip"/>
    </zip>
    <checksum file="${dist}/${appName}-bin.zip" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-bin.zip" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Zip the binary and source distributions -->
  <target name="zip-all" depends="zip-src,zip-bin" 
          description="Zip the binary and source distributions">
    <echo message="Zipped the binary and source distributions"/>
  </target>
  <!-- Tar and gz the distribution              -->
  <!-- Tar the documentation -->
  <target name="tar-docs" depends="docs" description="Tar the documentation">
    <echo message="Tarring the documentation"/>
    <tar destfile="${dist}/${appName}-${package.docs}.tar.gz" compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
    </tar> 
    <checksum file="${dist}/${appName}-${package.docs}.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.docs}.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the source and documentation together -->
  <target name="tar-src" depends="tar-docs"
          description="Tar the documentation">
    <echo message="Tarring the documentation"/>
    <tar destfile="${dist}/${appName}-src.tar.gz" compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the source code and the build files -->
      <tarfileset dir="${src.files.dir}">
        <patternset refid="src.files"/>
      </tarfileset>
    </tar> 
    <checksum file="${dist}/${appName}-src.tar.gz" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-src.tar.gz" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Tar the binary stand-alone distribution with the documentation -->
  <target name="tar-bin-stand-alone" depends="package-stand-alone,tar-docs" 
          description="Tar the binary stand-alone distribution 
                       with the documentation">
    <echo message="Tarring the binary stand-alone distribution with the documentation"/>
    <tar destfile="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" 
         compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the binary JAR files -->
      <tarfileset dir="${dist}" prefix="lib">
        <patternset refid="bin.jar"/>
      </tarfileset>
      <tarfileset dir=".">
        <include name="${mysql.jar}"/>
      </tarfileset>    </tar> 
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the binary web distribution with the documentation -->
  <target name="tar-bin-web" depends="package-web,tar-docs" 
          description="Tar the binary web distribution with the documentation">
    <echo message="Tarring the binary web distribution with the documentation"/>
    <tar destfile="${dist}/${appName}-${package.web}-bin.tar.gz" 
         compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the binary WAR files -->
      <tarfileset dir="${dist}">
        <patternset refid="bin.war"/>
      </tarfileset>
    </tar> 
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the binary distribution with the documentation -->
  <target name="tar-bin" depends="tar-bin-stand-alone,tar-bin-web" 
          description="Tar the binary distribution with the documentation">
    <echo message="Tarring the binary distribution with the documentation"/>
    <tar destfile="${dist}/${appName}-bin.tar.gz" compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the source code and the build files -->
      <tarfileset dir="${src.files.dir}">
        <patternset refid="src.files"/>
      </tarfileset>
      <!-- Include the binary JAR files -->
      <tarfileset dir="${dist}" prefix="lib">
        <patternset refid="bin.jar"/>
      </tarfileset>
      <tarfileset dir=".">
        <include name="${mysql.jar}"/>
      </tarfileset>
      <!-- Include the binary WAR files -->
      <tarfileset dir="${dist}">
        <patternset refid="bin.war"/>
      </tarfileset>
    </tar>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Tasks that use the zip files to construct tar files -->
  <!-- Tar the binary web distribution with the documentation -->
  <target name="tar-bin-web-new" depends="package-web,tar-docs,zip-bin-web" 
          description="Tar the binary web distribution with the documentation">
    <echo message="Tarring the binary web distribution with the documentation"/>
    <unzip src="${dist}/${appName}-${package.web}-bin.zip" dest="${tmp}/web"/>
    <tar destfile="${dist}/${appName}-${package.web}-bin.tar.gz" 
         compression="gzip">
      <tarfileset dir="${tmp}/web"/>
    </tar>
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the binary distribution with the documentation -->
  <target name="tar-bin-new" 
          depends="zip-bin,tar-bin-stand-alone,tar-bin-web-new"
          description="Tar the binary distribution with the documentation">
    <echo message="Tarring the binary distribution with the documentation"/>
    <delete failonerror="false" includeemptydirs="true">
      <fileset dir="${tmp}" includes="**"/>
    </delete>
    <unzip src="${dist}/${appName}-bin.zip" dest="${tmp}"/>
    <tar destfile="${dist}/${appName}-bin.tar.gz" compression="gzip">
      <tarfileset dir="${tmp}"/>
    </tar>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Tar the binary and source distributions -->
  <target name="tar-all" depends="tar-src,tar-bin" 
          description="Tar the binary and source distributions">
    <echo message="Tarred the binary and source distributions"/>
  </target>
  <!-- Distribution targets -->
  <!-- FTP targets         -->
  <!-- Place the documentation on FTP -->
<!--
  <target name="ftp-docs" depends="zip-docs,tar-docs" 
          description="Place the documentation on FTP">
    <echo message="Placing the documentation on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.src.dir}"
         action="send">
      <fileset dir="${dist}">
        <include name="${appName}-${package.docs}.*"/>
      </fileset>
    </ftp>
  </target>
-->
  <!-- Place the documentation on FTP -->
  <target name="ftp-docs" depends="zip-docs,tar-docs" 
          description="Place the documentation on FTP">
    <echo message="Placing the documentation on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.src.dir}"
         action="send"
         newer="true"
         timediffauto="true">
      <fileset dir="${dist}">
        <include name="${appName}-${package.docs}.*"/>
      </fileset>
    </ftp>
  </target>
  <!-- Place the source code on FTP -->
  <target name="ftp-src" depends="zip-src,tar-src" 
          description="Place the source code on FTP">
    <echo message="Placing the source code on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.src.dir}"
         action="send"
         newer="true"
         timediffauto="true">
      <fileset dir="${dist}">
        <include name="${appName}-src.*"/>
      </fileset>
    </ftp>
  </target>
  <!-- Place the binaries on FTP -->
  <target name="ftp-bin" depends="zip-bin,tar-bin" 
          description="Place the binaries on FTP">
    <echo message="Placing the binaries on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.bin.dir}"
         action="send"
         newer="true"
         timediffauto="true">
      <fileset dir="${dist}">
        <include name="${appName}*bin*"/>
      </fileset>
    </ftp>
  </target>
  <!-- Place everything on FTP -->
  <target name="ftp" description="Place everything on FTP">
    <echo message="Placing everything on FTP"/>
    <antcall target="ftp-docs"/>
    <antcall target="ftp-src"/>
    <antcall target="ftp-bin"/>
  </target>
  <!-- Place everything on FTP -->
<!--
  <target name="ftp" description="Place everything on FTP">
    <echo message="Placing everything on FTP"/>
    <input message="Please enter your username." addproperty="ftp.user"/>
    <input message="Please enter your password." addproperty="ftp.password"/>
    <splash showduration="0"/>
    <antcall target="ftp-docs"/>
    <antcall target="ftp-src"/>
    <antcall target="ftp-bin"/>
  </target>
-->
  <!-- Email targets       -->
  <!-- E-mail the documentation -->
  <target name="email-docs" depends="zip-docs,tar-docs" 
          description="E-mailing the documentation">
    <echo message="E-mailing the documentation"/>
    <mail from="${mail.from}"
          tolist="${mail.tolist}"
          mailhost="${mail.mailhost}"
          user="${mail.user}"
          password="${mail.password}"
          subject="${mail.subject}">
      <message>
        ${mail.message.docs}
      </message>
      <fileset dir="${dist}">
        <include name="${appName}-${package.docs}.*"/>
      </fileset>
    </mail>
  </target>
  <!-- Deploy the web application       -->
  <!-- 1. Copy the expanded web application -->
  <target name="deploy-copy-files" depends="copy-web" 
          description="Deploy the application by copying it to Tomcat">
    <echo message="Copying the expanded web application to CATALINA_HOME"/>
    <property environment="env"/>
    <copy todir="${build.web.web-inf}" file="${src.web.conf}/web.xml"/>
    <copy todir="${env.CATALINA_HOME}/webapps/${appName}">
      <fileset dir="${build.web.root}"/>
    </copy>
  </target>
  <!-- 2. Copy the WAR -->
  <target name="deploy-copy-war" depends="package-web" 
          description="Deploy the WAR by copying it to Tomcat">
    <echo message="Copying the WAR to CATALINA_HOME"/>
    <property environment="env"/>
    <copy file="${appName.war}" todir="${env.CATALINA_HOME}/webapps"/>
  </target>
  <!-- 3. Deploy the web application using a context XML file -->
  <target name="deploy-context" depends="copy-web" 
          description="Deploy the web application using a context XML file">
    <echo message="Deploying the web application using a context XML file"/>
    <property environment="env"/>
    <copy todir="${build.web.web-inf}" file="${src.web.conf}/web.xml"/>
    <copy todir="${env.CATALINA_HOME}/conf/Catalina/localhost" 
          file="${src.web.conf}/${appName}.xml"/>
  </target>
  <!-- The deploy task for web applications on Tomcat -->
  <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"/>
  <!-- 4. Deploy the WAR using the manager application -->
  <target name="deploy" depends="package-web" 
          description="Hot deploy the application">
    <echo message="Deploying the WAR to Tomcat"/>
    <deploy url="${manager.url}"
            username="${manager.user}"
            password="${manager.password}"  
            path="/${appName}"
            war="file:${appName.war}"
            update="true"/>
  </target>
  <!-- The undeploy task for web applications on Tomcat -->
  <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"/>
  <!-- Undeploy the web application -->
  <target name="undeploy" description="Undeploy the application">
    <echo message="Undeploying the WAR"/>
    <undeploy url="${manager.url}"
              username="${manager.user}"   
              password="${manager.password}"
              path="/${appName}"/>
  </target>
  <target name="clean" description="Clean up the working directories">
    <echo message="Cleaning up"/>
    <delete dir="${build}"/>
  </target>
</project>





Tar the documentation

 
<?xml version="1.0"?>
<project name="Example Application Build" default="build-both" basedir=".">
  
  <property file="build.properties"/>
  <!-- CVSROOT for the JSTL -->
  <property name="cvsroot" 
            value=":pserver:anoncvs@cvs.apache.org:/home/cvspublic" />
  <!-- CVSROOT for the MySQL connector -->
  <property name="mysql.cvsroot" 
            value=":pserver:anonymous@cvs.sourceforge.net:/cvsroot/mmmysql" />
  <!-- The master build classpath          --> 
  <path id="build.classpath">
    <pathelement location="${servlet24.jar}"/>
    <pathelement location="${jsp20.jar}"/>
    <pathelement location="${mysql.jar}"/>
    <pathelement path="${appName.jar}"/>
  </path>
  <!-- Javadoc file sets                   --> 
  <fileset id="javadoc" dir="${src}">
    <exclude name="*/conf/**"/>
    <exclude name="*/docs/*"/>
    <include name="shared/**"/>
    <include name="stand-alone/**"/>
    <include name="web/java/**"/>
  </fileset>  
  <!-- Properties and pattern sets for the packaging targets --> 
  <!-- The value of each property in this section is the setting -->
  <!-- for the "dir" attribute of file sets and tar file sets --> 
  <!-- Property and pattern set for the documentation -->
  <property name="docs.all.dir" value="${build}"/>
  <!-- Tar file sets cannot use file sets, so we must use a pattern set -->
  <patternset id="docs.all">
    <include name="docs/**"/>
  </patternset>
  <!-- Property and pattern set for the license and README -->
  <property name="docs.misc.dir" value="${src}/shared/docs"/>
  <!-- Tar file sets cannot use file sets, so we must use a pattern set -->
  <patternset id="docs.misc">
    <include name="README"/>
    <include name="LICENSE"/>
  </patternset>
  
  <!-- Property and pattern set for the source, -->
  <!-- build.xml, and build.properties -->
  <property name="src.files.dir" value="."/>
  <!-- Tar file sets cannot use file sets, so we must use a pattern set -->
  <patternset id="src.files">
    <include name="${src}/**"/>
    <include name="build.*"/>
  </patternset>
  <!-- Pattern set for the binary JAR -->
  <!-- Nothing else is needed because the directory that contains it -->
  <!-- is already in the ${dist} property and it"s used in a zip file set -->
  <!-- as well as a tar file set --> 
  <patternset id="bin.jar">
    <include name="*.jar"/>
  </patternset>
  <!-- Pattern set for the binary WAR -->
  <!-- Nothing else is needed because the directory that contains it -->
  <!-- is already in the ${dist} property and it"s used in a zip file set -->
  <!-- as well as a tar file set --> 
  <patternset id="bin.war">
    <include name="*.war"/>
  </patternset>
  <!-- Initialization target               --> 
  <!-- Create the working directories -->
  <target name="dir" description="Create the working directories">
    <echo message="Creating the working directories"/>
    <mkdir dir="${build.stand-alone.root}"/>
    <mkdir dir="${build.web.classes}"/>
    <mkdir dir="${dist}"/>
    <mkdir dir="${lib}"/>
  </target>
  <!-- CVS and build tasks for the JSTL and MySQL connector -->
  <!-- Update or check out required sources from CVS for the JSTL -->
  <target name="checkout-jstl" depends="dir" 
          description="Update or check out required sources
                       from CVS for the JSTL">
    <echo message="Checking out the required JSTL sources from CVS"/>
    <cvs cvsroot="${cvsroot}" quiet="true"
         command="checkout -P ${jstl.build}" 
         dest="${build}" compression="true" />
  </target>
  <!-- Update or check out required sources from CVS for the MySQL connector -->
  <target name="checkout-mysql-connector" depends="dir" 
          description="Update or check out required sources
          from CVS for the MySQL connector">
    <echo message="Checking out the required sources from CVS for the MySQL connector" />
    <cvs cvsroot="${mysql.cvsroot}" quiet="true"
         command="checkout" package="${mysql.build}"
         dest="${build}" compression="true" />
  </target>
  <!-- Build the JSTL from source -->
  <target name="build-jstl" depends="checkout-jstl" 
          description="Build the JSTL from source">
    <echo message="Building the JSTL from source"/>
    <ant antfile="build.xml" dir="${build}/${jstl.build}"/>
    <copy todir="${lib}">
      <fileset dir="${build}/${jstl.build}/${build}/lib">
        <include name="*.jar"/>
      </fileset>
    </copy>
  </target>
  <!-- Build the MySQL connector from source -->
  <target name="build-mysql-connector" depends="checkout-mysql-connector" 
          description="Build the MySQL connector from source">
    <echo message="Building the MySQL connector from source"/>
    <!-- The MySQL connector file needs this directory to exist -->
    <!-- Therefore we need to create it -->
    <mkdir dir="${build}/dist-mysql-jdbc"/>
    <ant antfile="build.xml" dir="${build}/${mysql.build}"/>
    <copy tofile="${mysql.jar}">
      <fileset dir="${build}/build-mysql-jdbc">
        <include name="mysql-connector*/*.jar"/>
      </fileset>
    </copy>
  </target>
  <!-- Compile the stand-alone application -->
  <target name="compile-stand-alone" depends="dir" 
          description="Compile stand-alone application">
    <echo message="Compiling the stand-alone application"/>
    <javac srcdir="${src.shared.java}" destdir="${build.stand-alone.root}"/>
    <javac srcdir="${src.stand-alone.java}" 
           destdir="${build.stand-alone.root}"/>  
  </target>
<!--
  <target name="stand-alone-complete" 
          description="Compile stand-alone application, 
          using CVS version of the MySQL connector">
    <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/>
    <antcall target="build-mysql-connector"/>
    <antcall target="package-stand-alone"/>
  </target>
  <target name="stand-alone-complete" 
          depends="build-mysql-connector, package-stand-alone" 
          description="Compile stand-alone application, 
          using CVS version of the MySQL connector">
    <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/>
  </target> 
-->
  <target name="stand-alone-complete" 
          depends="build-mysql-connector, package-stand-alone" 
          description="Compile stand-alone application, 
                       using CVS version of the MySQL connector">
    <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/>
  </target>
  <!-- Package the stand-alone application -->
  <target name="package-stand-alone" depends="compile-stand-alone" 
          description="Package the stand-alone application">
    <echo message="Creating the stand-alone JAR file"/>
    <copy file="${database.properties}" todir="${build.stand-alone.root}"/>
    <jar destfile="${appName.jar}" basedir="${build.stand-alone.root}"/>
  </target>
  <!-- Compile the web application -->
  <target name="compile-web" depends="dir" description="Compile web application">
    <echo message="Compiling the web application"/>
    <javac destdir="${build.web.classes}">
      <src path="${src.shared.java}"/>
    </javac>
    <javac srcdir="${src.web.java}" destdir="${build.web.classes}">
      <classpath refid="build.classpath"/>
    </javac>
  </target>
<!--
  <target name="web-complete" 
          description="Compile web application, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling web application, using CVS versions of the MySQL connector and the JSTL"/>
    <antcall target="build-mysql-connector"/>
    <antcall target="build-jstl"/>
    <antcall target="package-web"/>
  </target>
  <target name="web-complete" 
          depends="build-mysql-connector, build-jstl, package-web" 
          description="Compile web application, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiled web application, using CVS versions of the MySQL connector and the JSTL"/>
  </target>
-->
  <target name="web-complete" 
          depends="build-mysql-connector, build-jstl, package-web" 
          description="Compile web application, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling web application, using CVS versions of the MySQL connector and the JSTL"/>
  </target>
  <!-- Copy the web pages and configuration files -->
  <target name="copy-web" depends="compile-web" description="Copy the web files">
    <echo message="Copying the web pages and configuration files"/>
    <copy todir="${build.web.root}">
      <fileset dir="${src.web.pages}"/>
    </copy>
    <!-- Copy the tags -->
    <copy todir="${build.web.tags}">
      <fileset dir="${src.web.tags}"/>
    </copy>
    <copy todir="${build.web.web-inf}">
      <fileset dir="${src.web.conf}">
        <include name="*.tld"/>
      </fileset>
    </copy>
    <!-- Copy the JAR files -->
    <copy todir="${build.web.lib}">
      <fileset dir="${lib}"/>
    </copy>
    <!-- Copy the properties file -->
    <copy file="${database.properties}" todir="${build.web.classes}"/>
    <!-- No need to copy web.xml, as the WAR task does this for us -->
  </target>
  <!-- Build the WAR file -->
<!--
  <target name="package-web" depends="copy-web" description="Build the WAR">
    <echo message="Building the WAR file"/> 
    <war destfile="${appName.war}" basedir="${build.web.root}" 
         webxml="${src.web.conf}/web.xml"/>
  </target>
-->
  <!-- Build the WAR file in one step -->
  <target name="package-web" depends="compile-web" 
          description="Build the WAR file in one step">
    <echo message="Building the WAR file in one step"/> 
    <war destfile="${appName.war}" basedir="${src.web.pages}" 
         webxml="${src.web.conf}/web.xml">
      <lib dir="${lib}"/>
      <classes dir="${build.web.root}"/>
      <zipfileset dir="${src.web.tags}" prefix="WEB-INF/tags"/>
      <zipfileset file="${database.properties}" prefix="WEB-INF/classes"/>
      <zipfileset dir="${src.web.conf}" prefix="WEB-INF">
        <include name="*.tld"/>
      </zipfileset>
    </war>
  </target>
  <!-- Targets that work with both applications -->
<!--
  <target name="build-both" 
          description="Compile both applications, 
                       without CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling both applications, without CVS versions of the MySQL connector and the JSTL"/>
    <antcall target="package-stand-alone"/>
    <antcall target="package-web"/>
  </target>
  <target name="build-all" 
          description="Compile both applications, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling both applications, using CVS versions of the MySQL connector and the JSTL"/>
    <antcall target="stand-alone-complete"/>
    <antcall target="web-complete"/>
  </target>
-->
  <target name="build-both" 
          depends="package-stand-alone, package-web" 
          description="Compile both applications, 
                       without CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiled both applications, without CVS versions of the MySQL connector and the JSTL"/>
  </target>
  <target name="build-all" 
          depends="stand-alone-complete, web-complete" 
          description="Compile both applications, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiled both applications, using CVS versions of the MySQL connector and the JSTL"/>
  </target>

  <!-- Download the servlet JAR -->
  <target name="download-servlet-jar" depends="dir" 
          description="Download the servlet JAR">
    <echo message="Downloading the servlet JAR"/>
    <get src="http://www.ibiblio.org/maven/servletapi/jars/servletapi-2.4.jar"
         dest="${servlet24.jar}"
         verbose="true"/>
  </target>
  <!-- Download the JSP JAR -->
  <target name="download-jsp-jar" depends="dir" 
          description="Download the JSP JAR">
    <echo message="Downloading the JSP JAR"/>
    <get src="http://www.ibiblio.org/maven/jspapi/jars/jsp-api-2.0.jar"
         dest="${jsp20.jar}"
         verbose="true"/>
  </target>
  <!-- Building the documentation bundle        -->
  <!-- Checking that the documentation is up to date -->
  <target name="check-docs" 
          description="Check that the documentation is up to date">
    <echo message="Checking that the documentation is up to date"/>
    <condition property="docs.notRequired">
      <and>
        <uptodate targetfile="${dist}/${appName}-${package.docs}.zip">
          <srcfiles dir="${src}" includes="**"/>
        </uptodate>
        <uptodate targetfile="${dist}/${appName}-${package.docs}.tar.gz">
          <srcfiles dir="${src}" includes="**"/>
        </uptodate>
      </and>
    </condition>
  </target>  
  <!-- Generate Javadocs for the application -->
  <target name="javadocs" depends="dir,check-docs" 
          description="Generate Javadocs for the application" 
          unless="docs.notRequired">
    <echo message="Generating Javadocs for the application"/>
    <javadoc destdir="${docs}/api" windowtitle="${javadoc.windowtitle}">
      <fileset refid="javadoc"/>
      <doctitle>
        ${javadoc.doctitle}
      </doctitle>
      <classpath refid="build.classpath"/>
      <link href="http://java.sun.ru/j2se/${javadoc.j2se.version}/docs/api"/>  
      <link href="http://java.sun.ru/j2ee/${javadoc.j2ee.version}/docs/api"/> 
    </javadoc>
  </target>
   <!-- Generate Javadocs for the application, 
        using offline package-list files -->
  <target name="javadocs-offline" depends="dir,check-docs"
          description="Generate Javadocs for the application, 
                       using offline package-list files"
          unless="docs.notRequired">
    <echo message="Generating Javadocs for the application, 
                   using offline package-list files"/>
    <javadoc destdir="${docs}/api" windowtitle="${javadoc.windowtitle}">
      <fileset refid="javadoc"/>
      <doctitle>
        ${javadoc.doctitle}
      </doctitle>
      <classpath refid="build.classpath"/>
<!--
      <link href="http://java.sun.ru/j2se/${javadoc.j2se.version}/docs/api" 
            offline="true" packagelistLoc="${javadoc.j2se.offline}"/>  
      <link href="http://java.sun.ru/j2ee/${javadoc.j2ee.version}/docs/api"
            offline="true" packagelistLoc="${javadoc.j2ee.offline}"/> 
-->
      <link href="${javadoc.j2se.offline}" resolveLink="true"/>  
      <link href="${javadoc.j2ee.offline}" resolveLink="true"/> 
    </javadoc>
  </target>
  <!-- Assemble the documentation -->
  <target name="docs" depends="javadocs" 
          description="Assemble the documentation" unless="docs.notRequired">
    <echo message="Assembling the documentation"/>
    <copy todir="${docs}">
      <fileset dir="${src.shared.docs}">
        <include name="*.html"/>
      </fileset>
    </copy>
    <copy todir="${docs}/stand-alone">
      <fileset dir="${src.stand-alone.docs}">
        <include name="*.html"/>
      </fileset>
    </copy>
    <copy todir="${docs}/web">
      <fileset dir="${src.web.docs}">
        <include name="*.html"/>
      </fileset>
    </copy>
  </target>
  <!-- Zip the distribution                     -->
  <!-- Zip the documentation -->
  <target name="zip-docs" depends="docs" description="Zip the documentation">
    <echo message="Zipping the documentation"/>
    <zip destfile="${dist}/${appName}-${package.docs}.zip">
      <!-- Include the documentation -->
      <fileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </fileset>
      <!-- Include the license and the README -->
      <fileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-${package.docs}.zip" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.docs}.zip" forceOverwrite="true"  
              algorithm="SHA1"/>
  </target>
  <!-- Zip the source and documentation together -->
  <target name="zip-src" depends="zip-docs" 
          description="Zip the source and documentation together">
    <echo message="Zipping the source and documentation together"/>
    <zip destfile="${dist}/${appName}-src.zip">
      <!-- Include the source code and the build files -->
      <zipfileset src="${dist}/${appName}-${package.docs}.zip"/>
      <fileset dir="${src.files.dir}">
        <patternset refid="src.files"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-src.zip" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-src.zip" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Zip the binary stand-alone distribution with the documentation -->
  <target name="zip-bin-stand-alone" depends="package-stand-alone,zip-docs" 
          description="Zip the binary stand-alone distribution 
                       with the documentation">
    <echo message="Zipping the binary stand-alone distribution with the documentation"/>
    <zip destfile="${dist}/${appName}-${package.stand-alone}-bin.zip">
      <!-- Include the documentation -->
      <zipfileset src="${dist}/${appName}-${package.docs}.zip"/>
      <!-- Include the binary JAR files -->
      <zipfileset dir="${dist}" prefix="lib">
        <patternset refid="bin.jar"/>
      </zipfileset>
      <fileset dir=".">
        <include name="${mysql.jar}"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.zip" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.zip" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Zip the binary web distribution with the documentation -->
  <target name="zip-bin-web" depends="package-web,zip-docs" 
          description="Zip the binary web distribution with the documentation">
    <echo message="Zipping the binary web distribution with the documentation"/>
    <zip destfile="${dist}/${appName}-${package.web}-bin.zip">
      <!-- Include the documentation -->
      <zipfileset src="${dist}/${appName}-${package.docs}.zip"/>
      <!-- Include the binary WAR files -->
      <fileset dir="${dist}">
        <patternset refid="bin.war"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-${package.web}-bin.zip" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.web}-bin.zip" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Zip the binary distribution with the documentation -->
  <target name="zip-bin" depends="zip-bin-stand-alone,zip-bin-web" 
          description="Zip the binary distribution with the documentation">
    <echo message="Zipping the binary distribution with the documentation"/>
    <zip destfile="${dist}/${appName}-bin.zip" 
         duplicate="preserve" update="true">
      <zipgroupfileset dir="${dist}" includes="*.zip"/>
    </zip>
    <checksum file="${dist}/${appName}-bin.zip" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-bin.zip" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Zip the binary and source distributions -->
  <target name="zip-all" depends="zip-src,zip-bin" 
          description="Zip the binary and source distributions">
    <echo message="Zipped the binary and source distributions"/>
  </target>
  <!-- Tar and gz the distribution              -->
  <!-- Tar the documentation -->
  <target name="tar-docs" depends="docs" description="Tar the documentation">
    <echo message="Tarring the documentation"/>
    <tar destfile="${dist}/${appName}-${package.docs}.tar.gz" compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
    </tar> 
    <checksum file="${dist}/${appName}-${package.docs}.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.docs}.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the source and documentation together -->
  <target name="tar-src" depends="tar-docs"
          description="Tar the documentation">
    <echo message="Tarring the documentation"/>
    <tar destfile="${dist}/${appName}-src.tar.gz" compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the source code and the build files -->
      <tarfileset dir="${src.files.dir}">
        <patternset refid="src.files"/>
      </tarfileset>
    </tar> 
    <checksum file="${dist}/${appName}-src.tar.gz" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-src.tar.gz" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Tar the binary stand-alone distribution with the documentation -->
  <target name="tar-bin-stand-alone" depends="package-stand-alone,tar-docs" 
          description="Tar the binary stand-alone distribution 
                       with the documentation">
    <echo message="Tarring the binary stand-alone distribution with the documentation"/>
    <tar destfile="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" 
         compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the binary JAR files -->
      <tarfileset dir="${dist}" prefix="lib">
        <patternset refid="bin.jar"/>
      </tarfileset>
      <tarfileset dir=".">
        <include name="${mysql.jar}"/>
      </tarfileset>    </tar> 
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the binary web distribution with the documentation -->
  <target name="tar-bin-web" depends="package-web,tar-docs" 
          description="Tar the binary web distribution with the documentation">
    <echo message="Tarring the binary web distribution with the documentation"/>
    <tar destfile="${dist}/${appName}-${package.web}-bin.tar.gz" 
         compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the binary WAR files -->
      <tarfileset dir="${dist}">
        <patternset refid="bin.war"/>
      </tarfileset>
    </tar> 
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the binary distribution with the documentation -->
  <target name="tar-bin" depends="tar-bin-stand-alone,tar-bin-web" 
          description="Tar the binary distribution with the documentation">
    <echo message="Tarring the binary distribution with the documentation"/>
    <tar destfile="${dist}/${appName}-bin.tar.gz" compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the source code and the build files -->
      <tarfileset dir="${src.files.dir}">
        <patternset refid="src.files"/>
      </tarfileset>
      <!-- Include the binary JAR files -->
      <tarfileset dir="${dist}" prefix="lib">
        <patternset refid="bin.jar"/>
      </tarfileset>
      <tarfileset dir=".">
        <include name="${mysql.jar}"/>
      </tarfileset>
      <!-- Include the binary WAR files -->
      <tarfileset dir="${dist}">
        <patternset refid="bin.war"/>
      </tarfileset>
    </tar>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Tasks that use the zip files to construct tar files -->
  <!-- Tar the binary web distribution with the documentation -->
  <target name="tar-bin-web-new" depends="package-web,tar-docs,zip-bin-web" 
          description="Tar the binary web distribution with the documentation">
    <echo message="Tarring the binary web distribution with the documentation"/>
    <unzip src="${dist}/${appName}-${package.web}-bin.zip" dest="${tmp}/web"/>
    <tar destfile="${dist}/${appName}-${package.web}-bin.tar.gz" 
         compression="gzip">
      <tarfileset dir="${tmp}/web"/>
    </tar>
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the binary distribution with the documentation -->
  <target name="tar-bin-new" 
          depends="zip-bin,tar-bin-stand-alone,tar-bin-web-new"
          description="Tar the binary distribution with the documentation">
    <echo message="Tarring the binary distribution with the documentation"/>
    <delete failonerror="false" includeemptydirs="true">
      <fileset dir="${tmp}" includes="**"/>
    </delete>
    <unzip src="${dist}/${appName}-bin.zip" dest="${tmp}"/>
    <tar destfile="${dist}/${appName}-bin.tar.gz" compression="gzip">
      <tarfileset dir="${tmp}"/>
    </tar>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Tar the binary and source distributions -->
  <target name="tar-all" depends="tar-src,tar-bin" 
          description="Tar the binary and source distributions">
    <echo message="Tarred the binary and source distributions"/>
  </target>
  <!-- Distribution targets -->
  <!-- FTP targets         -->
  <!-- Place the documentation on FTP -->
<!--
  <target name="ftp-docs" depends="zip-docs,tar-docs" 
          description="Place the documentation on FTP">
    <echo message="Placing the documentation on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.src.dir}"
         action="send">
      <fileset dir="${dist}">
        <include name="${appName}-${package.docs}.*"/>
      </fileset>
    </ftp>
  </target>
-->
  <!-- Place the documentation on FTP -->
  <target name="ftp-docs" depends="zip-docs,tar-docs" 
          description="Place the documentation on FTP">
    <echo message="Placing the documentation on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.src.dir}"
         action="send"
         newer="true"
         timediffauto="true">
      <fileset dir="${dist}">
        <include name="${appName}-${package.docs}.*"/>
      </fileset>
    </ftp>
  </target>
  <!-- Place the source code on FTP -->
  <target name="ftp-src" depends="zip-src,tar-src" 
          description="Place the source code on FTP">
    <echo message="Placing the source code on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.src.dir}"
         action="send"
         newer="true"
         timediffauto="true">
      <fileset dir="${dist}">
        <include name="${appName}-src.*"/>
      </fileset>
    </ftp>
  </target>
  <!-- Place the binaries on FTP -->
  <target name="ftp-bin" depends="zip-bin,tar-bin" 
          description="Place the binaries on FTP">
    <echo message="Placing the binaries on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.bin.dir}"
         action="send"
         newer="true"
         timediffauto="true">
      <fileset dir="${dist}">
        <include name="${appName}*bin*"/>
      </fileset>
    </ftp>
  </target>
  <!-- Place everything on FTP -->
  <target name="ftp" description="Place everything on FTP">
    <echo message="Placing everything on FTP"/>
    <antcall target="ftp-docs"/>
    <antcall target="ftp-src"/>
    <antcall target="ftp-bin"/>
  </target>
  <!-- Place everything on FTP -->
<!--
  <target name="ftp" description="Place everything on FTP">
    <echo message="Placing everything on FTP"/>
    <input message="Please enter your username." addproperty="ftp.user"/>
    <input message="Please enter your password." addproperty="ftp.password"/>
    <splash showduration="0"/>
    <antcall target="ftp-docs"/>
    <antcall target="ftp-src"/>
    <antcall target="ftp-bin"/>
  </target>
-->
  <!-- Email targets       -->
  <!-- E-mail the documentation -->
  <target name="email-docs" depends="zip-docs,tar-docs" 
          description="E-mailing the documentation">
    <echo message="E-mailing the documentation"/>
    <mail from="${mail.from}"
          tolist="${mail.tolist}"
          mailhost="${mail.mailhost}"
          user="${mail.user}"
          password="${mail.password}"
          subject="${mail.subject}">
      <message>
        ${mail.message.docs}
      </message>
      <fileset dir="${dist}">
        <include name="${appName}-${package.docs}.*"/>
      </fileset>
    </mail>
  </target>
  <!-- Deploy the web application       -->
  <!-- 1. Copy the expanded web application -->
  <target name="deploy-copy-files" depends="copy-web" 
          description="Deploy the application by copying it to Tomcat">
    <echo message="Copying the expanded web application to CATALINA_HOME"/>
    <property environment="env"/>
    <copy todir="${build.web.web-inf}" file="${src.web.conf}/web.xml"/>
    <copy todir="${env.CATALINA_HOME}/webapps/${appName}">
      <fileset dir="${build.web.root}"/>
    </copy>
  </target>
  <!-- 2. Copy the WAR -->
  <target name="deploy-copy-war" depends="package-web" 
          description="Deploy the WAR by copying it to Tomcat">
    <echo message="Copying the WAR to CATALINA_HOME"/>
    <property environment="env"/>
    <copy file="${appName.war}" todir="${env.CATALINA_HOME}/webapps"/>
  </target>
  <!-- 3. Deploy the web application using a context XML file -->
  <target name="deploy-context" depends="copy-web" 
          description="Deploy the web application using a context XML file">
    <echo message="Deploying the web application using a context XML file"/>
    <property environment="env"/>
    <copy todir="${build.web.web-inf}" file="${src.web.conf}/web.xml"/>
    <copy todir="${env.CATALINA_HOME}/conf/Catalina/localhost" 
          file="${src.web.conf}/${appName}.xml"/>
  </target>
  <!-- The deploy task for web applications on Tomcat -->
  <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"/>
  <!-- 4. Deploy the WAR using the manager application -->
  <target name="deploy" depends="package-web" 
          description="Hot deploy the application">
    <echo message="Deploying the WAR to Tomcat"/>
    <deploy url="${manager.url}"
            username="${manager.user}"
            password="${manager.password}"  
            path="/${appName}"
            war="file:${appName.war}"
            update="true"/>
  </target>
  <!-- The undeploy task for web applications on Tomcat -->
  <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"/>
  <!-- Undeploy the web application -->
  <target name="undeploy" description="Undeploy the application">
    <echo message="Undeploying the WAR"/>
    <undeploy url="${manager.url}"
              username="${manager.user}"   
              password="${manager.password}"
              path="/${appName}"/>
  </target>
  <target name="clean" description="Clean up the working directories">
    <echo message="Cleaning up"/>
    <delete dir="${build}"/>
  </target>
</project>





Tar the source and documentation together

 
<?xml version="1.0"?>
<project name="Example Application Build" default="build-both" basedir=".">
  
  <property file="build.properties"/>
  <!-- CVSROOT for the JSTL -->
  <property name="cvsroot" 
            value=":pserver:anoncvs@cvs.apache.org:/home/cvspublic" />
  <!-- CVSROOT for the MySQL connector -->
  <property name="mysql.cvsroot" 
            value=":pserver:anonymous@cvs.sourceforge.net:/cvsroot/mmmysql" />
  <!-- The master build classpath          --> 
  <path id="build.classpath">
    <pathelement location="${servlet24.jar}"/>
    <pathelement location="${jsp20.jar}"/>
    <pathelement location="${mysql.jar}"/>
    <pathelement path="${appName.jar}"/>
  </path>
  <!-- Javadoc file sets                   --> 
  <fileset id="javadoc" dir="${src}">
    <exclude name="*/conf/**"/>
    <exclude name="*/docs/*"/>
    <include name="shared/**"/>
    <include name="stand-alone/**"/>
    <include name="web/java/**"/>
  </fileset>  
  <!-- Properties and pattern sets for the packaging targets --> 
  <!-- The value of each property in this section is the setting -->
  <!-- for the "dir" attribute of file sets and tar file sets --> 
  <!-- Property and pattern set for the documentation -->
  <property name="docs.all.dir" value="${build}"/>
  <!-- Tar file sets cannot use file sets, so we must use a pattern set -->
  <patternset id="docs.all">
    <include name="docs/**"/>
  </patternset>
  <!-- Property and pattern set for the license and README -->
  <property name="docs.misc.dir" value="${src}/shared/docs"/>
  <!-- Tar file sets cannot use file sets, so we must use a pattern set -->
  <patternset id="docs.misc">
    <include name="README"/>
    <include name="LICENSE"/>
  </patternset>
  
  <!-- Property and pattern set for the source, -->
  <!-- build.xml, and build.properties -->
  <property name="src.files.dir" value="."/>
  <!-- Tar file sets cannot use file sets, so we must use a pattern set -->
  <patternset id="src.files">
    <include name="${src}/**"/>
    <include name="build.*"/>
  </patternset>
  <!-- Pattern set for the binary JAR -->
  <!-- Nothing else is needed because the directory that contains it -->
  <!-- is already in the ${dist} property and it"s used in a zip file set -->
  <!-- as well as a tar file set --> 
  <patternset id="bin.jar">
    <include name="*.jar"/>
  </patternset>
  <!-- Pattern set for the binary WAR -->
  <!-- Nothing else is needed because the directory that contains it -->
  <!-- is already in the ${dist} property and it"s used in a zip file set -->
  <!-- as well as a tar file set --> 
  <patternset id="bin.war">
    <include name="*.war"/>
  </patternset>
  <!-- Initialization target               --> 
  <!-- Create the working directories -->
  <target name="dir" description="Create the working directories">
    <echo message="Creating the working directories"/>
    <mkdir dir="${build.stand-alone.root}"/>
    <mkdir dir="${build.web.classes}"/>
    <mkdir dir="${dist}"/>
    <mkdir dir="${lib}"/>
  </target>
  <!-- CVS and build tasks for the JSTL and MySQL connector -->
  <!-- Update or check out required sources from CVS for the JSTL -->
  <target name="checkout-jstl" depends="dir" 
          description="Update or check out required sources
                       from CVS for the JSTL">
    <echo message="Checking out the required JSTL sources from CVS"/>
    <cvs cvsroot="${cvsroot}" quiet="true"
         command="checkout -P ${jstl.build}" 
         dest="${build}" compression="true" />
  </target>
  <!-- Update or check out required sources from CVS for the MySQL connector -->
  <target name="checkout-mysql-connector" depends="dir" 
          description="Update or check out required sources
          from CVS for the MySQL connector">
    <echo message="Checking out the required sources from CVS for the MySQL connector" />
    <cvs cvsroot="${mysql.cvsroot}" quiet="true"
         command="checkout" package="${mysql.build}"
         dest="${build}" compression="true" />
  </target>
  <!-- Build the JSTL from source -->
  <target name="build-jstl" depends="checkout-jstl" 
          description="Build the JSTL from source">
    <echo message="Building the JSTL from source"/>
    <ant antfile="build.xml" dir="${build}/${jstl.build}"/>
    <copy todir="${lib}">
      <fileset dir="${build}/${jstl.build}/${build}/lib">
        <include name="*.jar"/>
      </fileset>
    </copy>
  </target>
  <!-- Build the MySQL connector from source -->
  <target name="build-mysql-connector" depends="checkout-mysql-connector" 
          description="Build the MySQL connector from source">
    <echo message="Building the MySQL connector from source"/>
    <!-- The MySQL connector file needs this directory to exist -->
    <!-- Therefore we need to create it -->
    <mkdir dir="${build}/dist-mysql-jdbc"/>
    <ant antfile="build.xml" dir="${build}/${mysql.build}"/>
    <copy tofile="${mysql.jar}">
      <fileset dir="${build}/build-mysql-jdbc">
        <include name="mysql-connector*/*.jar"/>
      </fileset>
    </copy>
  </target>
  <!-- Compile the stand-alone application -->
  <target name="compile-stand-alone" depends="dir" 
          description="Compile stand-alone application">
    <echo message="Compiling the stand-alone application"/>
    <javac srcdir="${src.shared.java}" destdir="${build.stand-alone.root}"/>
    <javac srcdir="${src.stand-alone.java}" 
           destdir="${build.stand-alone.root}"/>  
  </target>
<!--
  <target name="stand-alone-complete" 
          description="Compile stand-alone application, 
          using CVS version of the MySQL connector">
    <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/>
    <antcall target="build-mysql-connector"/>
    <antcall target="package-stand-alone"/>
  </target>
  <target name="stand-alone-complete" 
          depends="build-mysql-connector, package-stand-alone" 
          description="Compile stand-alone application, 
          using CVS version of the MySQL connector">
    <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/>
  </target> 
-->
  <target name="stand-alone-complete" 
          depends="build-mysql-connector, package-stand-alone" 
          description="Compile stand-alone application, 
                       using CVS version of the MySQL connector">
    <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/>
  </target>
  <!-- Package the stand-alone application -->
  <target name="package-stand-alone" depends="compile-stand-alone" 
          description="Package the stand-alone application">
    <echo message="Creating the stand-alone JAR file"/>
    <copy file="${database.properties}" todir="${build.stand-alone.root}"/>
    <jar destfile="${appName.jar}" basedir="${build.stand-alone.root}"/>
  </target>
  <!-- Compile the web application -->
  <target name="compile-web" depends="dir" description="Compile web application">
    <echo message="Compiling the web application"/>
    <javac destdir="${build.web.classes}">
      <src path="${src.shared.java}"/>
    </javac>
    <javac srcdir="${src.web.java}" destdir="${build.web.classes}">
      <classpath refid="build.classpath"/>
    </javac>
  </target>
<!--
  <target name="web-complete" 
          description="Compile web application, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling web application, using CVS versions of the MySQL connector and the JSTL"/>
    <antcall target="build-mysql-connector"/>
    <antcall target="build-jstl"/>
    <antcall target="package-web"/>
  </target>
  <target name="web-complete" 
          depends="build-mysql-connector, build-jstl, package-web" 
          description="Compile web application, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiled web application, using CVS versions of the MySQL connector and the JSTL"/>
  </target>
-->
  <target name="web-complete" 
          depends="build-mysql-connector, build-jstl, package-web" 
          description="Compile web application, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling web application, using CVS versions of the MySQL connector and the JSTL"/>
  </target>
  <!-- Copy the web pages and configuration files -->
  <target name="copy-web" depends="compile-web" description="Copy the web files">
    <echo message="Copying the web pages and configuration files"/>
    <copy todir="${build.web.root}">
      <fileset dir="${src.web.pages}"/>
    </copy>
    <!-- Copy the tags -->
    <copy todir="${build.web.tags}">
      <fileset dir="${src.web.tags}"/>
    </copy>
    <copy todir="${build.web.web-inf}">
      <fileset dir="${src.web.conf}">
        <include name="*.tld"/>
      </fileset>
    </copy>
    <!-- Copy the JAR files -->
    <copy todir="${build.web.lib}">
      <fileset dir="${lib}"/>
    </copy>
    <!-- Copy the properties file -->
    <copy file="${database.properties}" todir="${build.web.classes}"/>
    <!-- No need to copy web.xml, as the WAR task does this for us -->
  </target>
  <!-- Build the WAR file -->
<!--
  <target name="package-web" depends="copy-web" description="Build the WAR">
    <echo message="Building the WAR file"/> 
    <war destfile="${appName.war}" basedir="${build.web.root}" 
         webxml="${src.web.conf}/web.xml"/>
  </target>
-->
  <!-- Build the WAR file in one step -->
  <target name="package-web" depends="compile-web" 
          description="Build the WAR file in one step">
    <echo message="Building the WAR file in one step"/> 
    <war destfile="${appName.war}" basedir="${src.web.pages}" 
         webxml="${src.web.conf}/web.xml">
      <lib dir="${lib}"/>
      <classes dir="${build.web.root}"/>
      <zipfileset dir="${src.web.tags}" prefix="WEB-INF/tags"/>
      <zipfileset file="${database.properties}" prefix="WEB-INF/classes"/>
      <zipfileset dir="${src.web.conf}" prefix="WEB-INF">
        <include name="*.tld"/>
      </zipfileset>
    </war>
  </target>
  <!-- Targets that work with both applications -->
<!--
  <target name="build-both" 
          description="Compile both applications, 
                       without CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling both applications, without CVS versions of the MySQL connector and the JSTL"/>
    <antcall target="package-stand-alone"/>
    <antcall target="package-web"/>
  </target>
  <target name="build-all" 
          description="Compile both applications, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling both applications, using CVS versions of the MySQL connector and the JSTL"/>
    <antcall target="stand-alone-complete"/>
    <antcall target="web-complete"/>
  </target>
-->
  <target name="build-both" 
          depends="package-stand-alone, package-web" 
          description="Compile both applications, 
                       without CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiled both applications, without CVS versions of the MySQL connector and the JSTL"/>
  </target>
  <target name="build-all" 
          depends="stand-alone-complete, web-complete" 
          description="Compile both applications, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiled both applications, using CVS versions of the MySQL connector and the JSTL"/>
  </target>

  <!-- Download the servlet JAR -->
  <target name="download-servlet-jar" depends="dir" 
          description="Download the servlet JAR">
    <echo message="Downloading the servlet JAR"/>
    <get src="http://www.ibiblio.org/maven/servletapi/jars/servletapi-2.4.jar"
         dest="${servlet24.jar}"
         verbose="true"/>
  </target>
  <!-- Download the JSP JAR -->
  <target name="download-jsp-jar" depends="dir" 
          description="Download the JSP JAR">
    <echo message="Downloading the JSP JAR"/>
    <get src="http://www.ibiblio.org/maven/jspapi/jars/jsp-api-2.0.jar"
         dest="${jsp20.jar}"
         verbose="true"/>
  </target>
  <!-- Building the documentation bundle        -->
  <!-- Checking that the documentation is up to date -->
  <target name="check-docs" 
          description="Check that the documentation is up to date">
    <echo message="Checking that the documentation is up to date"/>
    <condition property="docs.notRequired">
      <and>
        <uptodate targetfile="${dist}/${appName}-${package.docs}.zip">
          <srcfiles dir="${src}" includes="**"/>
        </uptodate>
        <uptodate targetfile="${dist}/${appName}-${package.docs}.tar.gz">
          <srcfiles dir="${src}" includes="**"/>
        </uptodate>
      </and>
    </condition>
  </target>  
  <!-- Generate Javadocs for the application -->
  <target name="javadocs" depends="dir,check-docs" 
          description="Generate Javadocs for the application" 
          unless="docs.notRequired">
    <echo message="Generating Javadocs for the application"/>
    <javadoc destdir="${docs}/api" windowtitle="${javadoc.windowtitle}">
      <fileset refid="javadoc"/>
      <doctitle>
        ${javadoc.doctitle}
      </doctitle>
      <classpath refid="build.classpath"/>
      <link href="http://java.sun.ru/j2se/${javadoc.j2se.version}/docs/api"/>  
      <link href="http://java.sun.ru/j2ee/${javadoc.j2ee.version}/docs/api"/> 
    </javadoc>
  </target>
   <!-- Generate Javadocs for the application, 
        using offline package-list files -->
  <target name="javadocs-offline" depends="dir,check-docs"
          description="Generate Javadocs for the application, 
                       using offline package-list files"
          unless="docs.notRequired">
    <echo message="Generating Javadocs for the application, 
                   using offline package-list files"/>
    <javadoc destdir="${docs}/api" windowtitle="${javadoc.windowtitle}">
      <fileset refid="javadoc"/>
      <doctitle>
        ${javadoc.doctitle}
      </doctitle>
      <classpath refid="build.classpath"/>
<!--
      <link href="http://java.sun.ru/j2se/${javadoc.j2se.version}/docs/api" 
            offline="true" packagelistLoc="${javadoc.j2se.offline}"/>  
      <link href="http://java.sun.ru/j2ee/${javadoc.j2ee.version}/docs/api"
            offline="true" packagelistLoc="${javadoc.j2ee.offline}"/> 
-->
      <link href="${javadoc.j2se.offline}" resolveLink="true"/>  
      <link href="${javadoc.j2ee.offline}" resolveLink="true"/> 
    </javadoc>
  </target>
  <!-- Assemble the documentation -->
  <target name="docs" depends="javadocs" 
          description="Assemble the documentation" unless="docs.notRequired">
    <echo message="Assembling the documentation"/>
    <copy todir="${docs}">
      <fileset dir="${src.shared.docs}">
        <include name="*.html"/>
      </fileset>
    </copy>
    <copy todir="${docs}/stand-alone">
      <fileset dir="${src.stand-alone.docs}">
        <include name="*.html"/>
      </fileset>
    </copy>
    <copy todir="${docs}/web">
      <fileset dir="${src.web.docs}">
        <include name="*.html"/>
      </fileset>
    </copy>
  </target>
  <!-- Zip the distribution                     -->
  <!-- Zip the documentation -->
  <target name="zip-docs" depends="docs" description="Zip the documentation">
    <echo message="Zipping the documentation"/>
    <zip destfile="${dist}/${appName}-${package.docs}.zip">
      <!-- Include the documentation -->
      <fileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </fileset>
      <!-- Include the license and the README -->
      <fileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-${package.docs}.zip" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.docs}.zip" forceOverwrite="true"  
              algorithm="SHA1"/>
  </target>
  <!-- Zip the source and documentation together -->
  <target name="zip-src" depends="zip-docs" 
          description="Zip the source and documentation together">
    <echo message="Zipping the source and documentation together"/>
    <zip destfile="${dist}/${appName}-src.zip">
      <!-- Include the source code and the build files -->
      <zipfileset src="${dist}/${appName}-${package.docs}.zip"/>
      <fileset dir="${src.files.dir}">
        <patternset refid="src.files"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-src.zip" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-src.zip" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Zip the binary stand-alone distribution with the documentation -->
  <target name="zip-bin-stand-alone" depends="package-stand-alone,zip-docs" 
          description="Zip the binary stand-alone distribution 
                       with the documentation">
    <echo message="Zipping the binary stand-alone distribution with the documentation"/>
    <zip destfile="${dist}/${appName}-${package.stand-alone}-bin.zip">
      <!-- Include the documentation -->
      <zipfileset src="${dist}/${appName}-${package.docs}.zip"/>
      <!-- Include the binary JAR files -->
      <zipfileset dir="${dist}" prefix="lib">
        <patternset refid="bin.jar"/>
      </zipfileset>
      <fileset dir=".">
        <include name="${mysql.jar}"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.zip" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.zip" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Zip the binary web distribution with the documentation -->
  <target name="zip-bin-web" depends="package-web,zip-docs" 
          description="Zip the binary web distribution with the documentation">
    <echo message="Zipping the binary web distribution with the documentation"/>
    <zip destfile="${dist}/${appName}-${package.web}-bin.zip">
      <!-- Include the documentation -->
      <zipfileset src="${dist}/${appName}-${package.docs}.zip"/>
      <!-- Include the binary WAR files -->
      <fileset dir="${dist}">
        <patternset refid="bin.war"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-${package.web}-bin.zip" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.web}-bin.zip" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Zip the binary distribution with the documentation -->
  <target name="zip-bin" depends="zip-bin-stand-alone,zip-bin-web" 
          description="Zip the binary distribution with the documentation">
    <echo message="Zipping the binary distribution with the documentation"/>
    <zip destfile="${dist}/${appName}-bin.zip" 
         duplicate="preserve" update="true">
      <zipgroupfileset dir="${dist}" includes="*.zip"/>
    </zip>
    <checksum file="${dist}/${appName}-bin.zip" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-bin.zip" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Zip the binary and source distributions -->
  <target name="zip-all" depends="zip-src,zip-bin" 
          description="Zip the binary and source distributions">
    <echo message="Zipped the binary and source distributions"/>
  </target>
  <!-- Tar and gz the distribution              -->
  <!-- Tar the documentation -->
  <target name="tar-docs" depends="docs" description="Tar the documentation">
    <echo message="Tarring the documentation"/>
    <tar destfile="${dist}/${appName}-${package.docs}.tar.gz" compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
    </tar> 
    <checksum file="${dist}/${appName}-${package.docs}.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.docs}.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the source and documentation together -->
  <target name="tar-src" depends="tar-docs"
          description="Tar the documentation">
    <echo message="Tarring the documentation"/>
    <tar destfile="${dist}/${appName}-src.tar.gz" compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the source code and the build files -->
      <tarfileset dir="${src.files.dir}">
        <patternset refid="src.files"/>
      </tarfileset>
    </tar> 
    <checksum file="${dist}/${appName}-src.tar.gz" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-src.tar.gz" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Tar the binary stand-alone distribution with the documentation -->
  <target name="tar-bin-stand-alone" depends="package-stand-alone,tar-docs" 
          description="Tar the binary stand-alone distribution 
                       with the documentation">
    <echo message="Tarring the binary stand-alone distribution with the documentation"/>
    <tar destfile="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" 
         compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the binary JAR files -->
      <tarfileset dir="${dist}" prefix="lib">
        <patternset refid="bin.jar"/>
      </tarfileset>
      <tarfileset dir=".">
        <include name="${mysql.jar}"/>
      </tarfileset>    </tar> 
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the binary web distribution with the documentation -->
  <target name="tar-bin-web" depends="package-web,tar-docs" 
          description="Tar the binary web distribution with the documentation">
    <echo message="Tarring the binary web distribution with the documentation"/>
    <tar destfile="${dist}/${appName}-${package.web}-bin.tar.gz" 
         compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the binary WAR files -->
      <tarfileset dir="${dist}">
        <patternset refid="bin.war"/>
      </tarfileset>
    </tar> 
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the binary distribution with the documentation -->
  <target name="tar-bin" depends="tar-bin-stand-alone,tar-bin-web" 
          description="Tar the binary distribution with the documentation">
    <echo message="Tarring the binary distribution with the documentation"/>
    <tar destfile="${dist}/${appName}-bin.tar.gz" compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the source code and the build files -->
      <tarfileset dir="${src.files.dir}">
        <patternset refid="src.files"/>
      </tarfileset>
      <!-- Include the binary JAR files -->
      <tarfileset dir="${dist}" prefix="lib">
        <patternset refid="bin.jar"/>
      </tarfileset>
      <tarfileset dir=".">
        <include name="${mysql.jar}"/>
      </tarfileset>
      <!-- Include the binary WAR files -->
      <tarfileset dir="${dist}">
        <patternset refid="bin.war"/>
      </tarfileset>
    </tar>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Tasks that use the zip files to construct tar files -->
  <!-- Tar the binary web distribution with the documentation -->
  <target name="tar-bin-web-new" depends="package-web,tar-docs,zip-bin-web" 
          description="Tar the binary web distribution with the documentation">
    <echo message="Tarring the binary web distribution with the documentation"/>
    <unzip src="${dist}/${appName}-${package.web}-bin.zip" dest="${tmp}/web"/>
    <tar destfile="${dist}/${appName}-${package.web}-bin.tar.gz" 
         compression="gzip">
      <tarfileset dir="${tmp}/web"/>
    </tar>
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the binary distribution with the documentation -->
  <target name="tar-bin-new" 
          depends="zip-bin,tar-bin-stand-alone,tar-bin-web-new"
          description="Tar the binary distribution with the documentation">
    <echo message="Tarring the binary distribution with the documentation"/>
    <delete failonerror="false" includeemptydirs="true">
      <fileset dir="${tmp}" includes="**"/>
    </delete>
    <unzip src="${dist}/${appName}-bin.zip" dest="${tmp}"/>
    <tar destfile="${dist}/${appName}-bin.tar.gz" compression="gzip">
      <tarfileset dir="${tmp}"/>
    </tar>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Tar the binary and source distributions -->
  <target name="tar-all" depends="tar-src,tar-bin" 
          description="Tar the binary and source distributions">
    <echo message="Tarred the binary and source distributions"/>
  </target>
  <!-- Distribution targets -->
  <!-- FTP targets         -->
  <!-- Place the documentation on FTP -->
<!--
  <target name="ftp-docs" depends="zip-docs,tar-docs" 
          description="Place the documentation on FTP">
    <echo message="Placing the documentation on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.src.dir}"
         action="send">
      <fileset dir="${dist}">
        <include name="${appName}-${package.docs}.*"/>
      </fileset>
    </ftp>
  </target>
-->
  <!-- Place the documentation on FTP -->
  <target name="ftp-docs" depends="zip-docs,tar-docs" 
          description="Place the documentation on FTP">
    <echo message="Placing the documentation on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.src.dir}"
         action="send"
         newer="true"
         timediffauto="true">
      <fileset dir="${dist}">
        <include name="${appName}-${package.docs}.*"/>
      </fileset>
    </ftp>
  </target>
  <!-- Place the source code on FTP -->
  <target name="ftp-src" depends="zip-src,tar-src" 
          description="Place the source code on FTP">
    <echo message="Placing the source code on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.src.dir}"
         action="send"
         newer="true"
         timediffauto="true">
      <fileset dir="${dist}">
        <include name="${appName}-src.*"/>
      </fileset>
    </ftp>
  </target>
  <!-- Place the binaries on FTP -->
  <target name="ftp-bin" depends="zip-bin,tar-bin" 
          description="Place the binaries on FTP">
    <echo message="Placing the binaries on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.bin.dir}"
         action="send"
         newer="true"
         timediffauto="true">
      <fileset dir="${dist}">
        <include name="${appName}*bin*"/>
      </fileset>
    </ftp>
  </target>
  <!-- Place everything on FTP -->
  <target name="ftp" description="Place everything on FTP">
    <echo message="Placing everything on FTP"/>
    <antcall target="ftp-docs"/>
    <antcall target="ftp-src"/>
    <antcall target="ftp-bin"/>
  </target>
  <!-- Place everything on FTP -->
<!--
  <target name="ftp" description="Place everything on FTP">
    <echo message="Placing everything on FTP"/>
    <input message="Please enter your username." addproperty="ftp.user"/>
    <input message="Please enter your password." addproperty="ftp.password"/>
    <splash showduration="0"/>
    <antcall target="ftp-docs"/>
    <antcall target="ftp-src"/>
    <antcall target="ftp-bin"/>
  </target>
-->
  <!-- Email targets       -->
  <!-- E-mail the documentation -->
  <target name="email-docs" depends="zip-docs,tar-docs" 
          description="E-mailing the documentation">
    <echo message="E-mailing the documentation"/>
    <mail from="${mail.from}"
          tolist="${mail.tolist}"
          mailhost="${mail.mailhost}"
          user="${mail.user}"
          password="${mail.password}"
          subject="${mail.subject}">
      <message>
        ${mail.message.docs}
      </message>
      <fileset dir="${dist}">
        <include name="${appName}-${package.docs}.*"/>
      </fileset>
    </mail>
  </target>
  <!-- Deploy the web application       -->
  <!-- 1. Copy the expanded web application -->
  <target name="deploy-copy-files" depends="copy-web" 
          description="Deploy the application by copying it to Tomcat">
    <echo message="Copying the expanded web application to CATALINA_HOME"/>
    <property environment="env"/>
    <copy todir="${build.web.web-inf}" file="${src.web.conf}/web.xml"/>
    <copy todir="${env.CATALINA_HOME}/webapps/${appName}">
      <fileset dir="${build.web.root}"/>
    </copy>
  </target>
  <!-- 2. Copy the WAR -->
  <target name="deploy-copy-war" depends="package-web" 
          description="Deploy the WAR by copying it to Tomcat">
    <echo message="Copying the WAR to CATALINA_HOME"/>
    <property environment="env"/>
    <copy file="${appName.war}" todir="${env.CATALINA_HOME}/webapps"/>
  </target>
  <!-- 3. Deploy the web application using a context XML file -->
  <target name="deploy-context" depends="copy-web" 
          description="Deploy the web application using a context XML file">
    <echo message="Deploying the web application using a context XML file"/>
    <property environment="env"/>
    <copy todir="${build.web.web-inf}" file="${src.web.conf}/web.xml"/>
    <copy todir="${env.CATALINA_HOME}/conf/Catalina/localhost" 
          file="${src.web.conf}/${appName}.xml"/>
  </target>
  <!-- The deploy task for web applications on Tomcat -->
  <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"/>
  <!-- 4. Deploy the WAR using the manager application -->
  <target name="deploy" depends="package-web" 
          description="Hot deploy the application">
    <echo message="Deploying the WAR to Tomcat"/>
    <deploy url="${manager.url}"
            username="${manager.user}"
            password="${manager.password}"  
            path="/${appName}"
            war="file:${appName.war}"
            update="true"/>
  </target>
  <!-- The undeploy task for web applications on Tomcat -->
  <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"/>
  <!-- Undeploy the web application -->
  <target name="undeploy" description="Undeploy the application">
    <echo message="Undeploying the WAR"/>
    <undeploy url="${manager.url}"
              username="${manager.user}"   
              password="${manager.password}"
              path="/${appName}"/>
  </target>
  <target name="clean" description="Clean up the working directories">
    <echo message="Cleaning up"/>
    <delete dir="${build}"/>
  </target>
</project>





Tasks that use the zip files to construct tar files

 
<?xml version="1.0"?>
<project name="Example Application Build" default="build-both" basedir=".">
  
  <property file="build.properties"/>
  <!-- CVSROOT for the JSTL -->
  <property name="cvsroot" 
            value=":pserver:anoncvs@cvs.apache.org:/home/cvspublic" />
  <!-- CVSROOT for the MySQL connector -->
  <property name="mysql.cvsroot" 
            value=":pserver:anonymous@cvs.sourceforge.net:/cvsroot/mmmysql" />
  <!-- The master build classpath          --> 
  <path id="build.classpath">
    <pathelement location="${servlet24.jar}"/>
    <pathelement location="${jsp20.jar}"/>
    <pathelement location="${mysql.jar}"/>
    <pathelement path="${appName.jar}"/>
  </path>
  <!-- Javadoc file sets                   --> 
  <fileset id="javadoc" dir="${src}">
    <exclude name="*/conf/**"/>
    <exclude name="*/docs/*"/>
    <include name="shared/**"/>
    <include name="stand-alone/**"/>
    <include name="web/java/**"/>
  </fileset>  
  <!-- Properties and pattern sets for the packaging targets --> 
  <!-- The value of each property in this section is the setting -->
  <!-- for the "dir" attribute of file sets and tar file sets --> 
  <!-- Property and pattern set for the documentation -->
  <property name="docs.all.dir" value="${build}"/>
  <!-- Tar file sets cannot use file sets, so we must use a pattern set -->
  <patternset id="docs.all">
    <include name="docs/**"/>
  </patternset>
  <!-- Property and pattern set for the license and README -->
  <property name="docs.misc.dir" value="${src}/shared/docs"/>
  <!-- Tar file sets cannot use file sets, so we must use a pattern set -->
  <patternset id="docs.misc">
    <include name="README"/>
    <include name="LICENSE"/>
  </patternset>
  
  <!-- Property and pattern set for the source, -->
  <!-- build.xml, and build.properties -->
  <property name="src.files.dir" value="."/>
  <!-- Tar file sets cannot use file sets, so we must use a pattern set -->
  <patternset id="src.files">
    <include name="${src}/**"/>
    <include name="build.*"/>
  </patternset>
  <!-- Pattern set for the binary JAR -->
  <!-- Nothing else is needed because the directory that contains it -->
  <!-- is already in the ${dist} property and it"s used in a zip file set -->
  <!-- as well as a tar file set --> 
  <patternset id="bin.jar">
    <include name="*.jar"/>
  </patternset>
  <!-- Pattern set for the binary WAR -->
  <!-- Nothing else is needed because the directory that contains it -->
  <!-- is already in the ${dist} property and it"s used in a zip file set -->
  <!-- as well as a tar file set --> 
  <patternset id="bin.war">
    <include name="*.war"/>
  </patternset>
  <!-- Initialization target               --> 
  <!-- Create the working directories -->
  <target name="dir" description="Create the working directories">
    <echo message="Creating the working directories"/>
    <mkdir dir="${build.stand-alone.root}"/>
    <mkdir dir="${build.web.classes}"/>
    <mkdir dir="${dist}"/>
    <mkdir dir="${lib}"/>
  </target>
  <!-- CVS and build tasks for the JSTL and MySQL connector -->
  <!-- Update or check out required sources from CVS for the JSTL -->
  <target name="checkout-jstl" depends="dir" 
          description="Update or check out required sources
                       from CVS for the JSTL">
    <echo message="Checking out the required JSTL sources from CVS"/>
    <cvs cvsroot="${cvsroot}" quiet="true"
         command="checkout -P ${jstl.build}" 
         dest="${build}" compression="true" />
  </target>
  <!-- Update or check out required sources from CVS for the MySQL connector -->
  <target name="checkout-mysql-connector" depends="dir" 
          description="Update or check out required sources
          from CVS for the MySQL connector">
    <echo message="Checking out the required sources from CVS for the MySQL connector" />
    <cvs cvsroot="${mysql.cvsroot}" quiet="true"
         command="checkout" package="${mysql.build}"
         dest="${build}" compression="true" />
  </target>
  <!-- Build the JSTL from source -->
  <target name="build-jstl" depends="checkout-jstl" 
          description="Build the JSTL from source">
    <echo message="Building the JSTL from source"/>
    <ant antfile="build.xml" dir="${build}/${jstl.build}"/>
    <copy todir="${lib}">
      <fileset dir="${build}/${jstl.build}/${build}/lib">
        <include name="*.jar"/>
      </fileset>
    </copy>
  </target>
  <!-- Build the MySQL connector from source -->
  <target name="build-mysql-connector" depends="checkout-mysql-connector" 
          description="Build the MySQL connector from source">
    <echo message="Building the MySQL connector from source"/>
    <!-- The MySQL connector file needs this directory to exist -->
    <!-- Therefore we need to create it -->
    <mkdir dir="${build}/dist-mysql-jdbc"/>
    <ant antfile="build.xml" dir="${build}/${mysql.build}"/>
    <copy tofile="${mysql.jar}">
      <fileset dir="${build}/build-mysql-jdbc">
        <include name="mysql-connector*/*.jar"/>
      </fileset>
    </copy>
  </target>
  <!-- Compile the stand-alone application -->
  <target name="compile-stand-alone" depends="dir" 
          description="Compile stand-alone application">
    <echo message="Compiling the stand-alone application"/>
    <javac srcdir="${src.shared.java}" destdir="${build.stand-alone.root}"/>
    <javac srcdir="${src.stand-alone.java}" 
           destdir="${build.stand-alone.root}"/>  
  </target>
<!--
  <target name="stand-alone-complete" 
          description="Compile stand-alone application, 
          using CVS version of the MySQL connector">
    <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/>
    <antcall target="build-mysql-connector"/>
    <antcall target="package-stand-alone"/>
  </target>
  <target name="stand-alone-complete" 
          depends="build-mysql-connector, package-stand-alone" 
          description="Compile stand-alone application, 
          using CVS version of the MySQL connector">
    <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/>
  </target> 
-->
  <target name="stand-alone-complete" 
          depends="build-mysql-connector, package-stand-alone" 
          description="Compile stand-alone application, 
                       using CVS version of the MySQL connector">
    <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/>
  </target>
  <!-- Package the stand-alone application -->
  <target name="package-stand-alone" depends="compile-stand-alone" 
          description="Package the stand-alone application">
    <echo message="Creating the stand-alone JAR file"/>
    <copy file="${database.properties}" todir="${build.stand-alone.root}"/>
    <jar destfile="${appName.jar}" basedir="${build.stand-alone.root}"/>
  </target>
  <!-- Compile the web application -->
  <target name="compile-web" depends="dir" description="Compile web application">
    <echo message="Compiling the web application"/>
    <javac destdir="${build.web.classes}">
      <src path="${src.shared.java}"/>
    </javac>
    <javac srcdir="${src.web.java}" destdir="${build.web.classes}">
      <classpath refid="build.classpath"/>
    </javac>
  </target>
<!--
  <target name="web-complete" 
          description="Compile web application, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling web application, using CVS versions of the MySQL connector and the JSTL"/>
    <antcall target="build-mysql-connector"/>
    <antcall target="build-jstl"/>
    <antcall target="package-web"/>
  </target>
  <target name="web-complete" 
          depends="build-mysql-connector, build-jstl, package-web" 
          description="Compile web application, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiled web application, using CVS versions of the MySQL connector and the JSTL"/>
  </target>
-->
  <target name="web-complete" 
          depends="build-mysql-connector, build-jstl, package-web" 
          description="Compile web application, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling web application, using CVS versions of the MySQL connector and the JSTL"/>
  </target>
  <!-- Copy the web pages and configuration files -->
  <target name="copy-web" depends="compile-web" description="Copy the web files">
    <echo message="Copying the web pages and configuration files"/>
    <copy todir="${build.web.root}">
      <fileset dir="${src.web.pages}"/>
    </copy>
    <!-- Copy the tags -->
    <copy todir="${build.web.tags}">
      <fileset dir="${src.web.tags}"/>
    </copy>
    <copy todir="${build.web.web-inf}">
      <fileset dir="${src.web.conf}">
        <include name="*.tld"/>
      </fileset>
    </copy>
    <!-- Copy the JAR files -->
    <copy todir="${build.web.lib}">
      <fileset dir="${lib}"/>
    </copy>
    <!-- Copy the properties file -->
    <copy file="${database.properties}" todir="${build.web.classes}"/>
    <!-- No need to copy web.xml, as the WAR task does this for us -->
  </target>
  <!-- Build the WAR file -->
<!--
  <target name="package-web" depends="copy-web" description="Build the WAR">
    <echo message="Building the WAR file"/> 
    <war destfile="${appName.war}" basedir="${build.web.root}" 
         webxml="${src.web.conf}/web.xml"/>
  </target>
-->
  <!-- Build the WAR file in one step -->
  <target name="package-web" depends="compile-web" 
          description="Build the WAR file in one step">
    <echo message="Building the WAR file in one step"/> 
    <war destfile="${appName.war}" basedir="${src.web.pages}" 
         webxml="${src.web.conf}/web.xml">
      <lib dir="${lib}"/>
      <classes dir="${build.web.root}"/>
      <zipfileset dir="${src.web.tags}" prefix="WEB-INF/tags"/>
      <zipfileset file="${database.properties}" prefix="WEB-INF/classes"/>
      <zipfileset dir="${src.web.conf}" prefix="WEB-INF">
        <include name="*.tld"/>
      </zipfileset>
    </war>
  </target>
  <!-- Targets that work with both applications -->
<!--
  <target name="build-both" 
          description="Compile both applications, 
                       without CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling both applications, without CVS versions of the MySQL connector and the JSTL"/>
    <antcall target="package-stand-alone"/>
    <antcall target="package-web"/>
  </target>
  <target name="build-all" 
          description="Compile both applications, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiling both applications, using CVS versions of the MySQL connector and the JSTL"/>
    <antcall target="stand-alone-complete"/>
    <antcall target="web-complete"/>
  </target>
-->
  <target name="build-both" 
          depends="package-stand-alone, package-web" 
          description="Compile both applications, 
                       without CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiled both applications, without CVS versions of the MySQL connector and the JSTL"/>
  </target>
  <target name="build-all" 
          depends="stand-alone-complete, web-complete" 
          description="Compile both applications, 
                       using CVS versions of the MySQL connector and the JSTL">
    <echo message="Compiled both applications, using CVS versions of the MySQL connector and the JSTL"/>
  </target>

  <!-- Download the servlet JAR -->
  <target name="download-servlet-jar" depends="dir" 
          description="Download the servlet JAR">
    <echo message="Downloading the servlet JAR"/>
    <get src="http://www.ibiblio.org/maven/servletapi/jars/servletapi-2.4.jar"
         dest="${servlet24.jar}"
         verbose="true"/>
  </target>
  <!-- Download the JSP JAR -->
  <target name="download-jsp-jar" depends="dir" 
          description="Download the JSP JAR">
    <echo message="Downloading the JSP JAR"/>
    <get src="http://www.ibiblio.org/maven/jspapi/jars/jsp-api-2.0.jar"
         dest="${jsp20.jar}"
         verbose="true"/>
  </target>
  <!-- Building the documentation bundle        -->
  <!-- Checking that the documentation is up to date -->
  <target name="check-docs" 
          description="Check that the documentation is up to date">
    <echo message="Checking that the documentation is up to date"/>
    <condition property="docs.notRequired">
      <and>
        <uptodate targetfile="${dist}/${appName}-${package.docs}.zip">
          <srcfiles dir="${src}" includes="**"/>
        </uptodate>
        <uptodate targetfile="${dist}/${appName}-${package.docs}.tar.gz">
          <srcfiles dir="${src}" includes="**"/>
        </uptodate>
      </and>
    </condition>
  </target>  
  <!-- Generate Javadocs for the application -->
  <target name="javadocs" depends="dir,check-docs" 
          description="Generate Javadocs for the application" 
          unless="docs.notRequired">
    <echo message="Generating Javadocs for the application"/>
    <javadoc destdir="${docs}/api" windowtitle="${javadoc.windowtitle}">
      <fileset refid="javadoc"/>
      <doctitle>
        ${javadoc.doctitle}
      </doctitle>
      <classpath refid="build.classpath"/>
      <link href="http://java.sun.ru/j2se/${javadoc.j2se.version}/docs/api"/>  
      <link href="http://java.sun.ru/j2ee/${javadoc.j2ee.version}/docs/api"/> 
    </javadoc>
  </target>
   <!-- Generate Javadocs for the application, 
        using offline package-list files -->
  <target name="javadocs-offline" depends="dir,check-docs"
          description="Generate Javadocs for the application, 
                       using offline package-list files"
          unless="docs.notRequired">
    <echo message="Generating Javadocs for the application, 
                   using offline package-list files"/>
    <javadoc destdir="${docs}/api" windowtitle="${javadoc.windowtitle}">
      <fileset refid="javadoc"/>
      <doctitle>
        ${javadoc.doctitle}
      </doctitle>
      <classpath refid="build.classpath"/>
<!--
      <link href="http://java.sun.ru/j2se/${javadoc.j2se.version}/docs/api" 
            offline="true" packagelistLoc="${javadoc.j2se.offline}"/>  
      <link href="http://java.sun.ru/j2ee/${javadoc.j2ee.version}/docs/api"
            offline="true" packagelistLoc="${javadoc.j2ee.offline}"/> 
-->
      <link href="${javadoc.j2se.offline}" resolveLink="true"/>  
      <link href="${javadoc.j2ee.offline}" resolveLink="true"/> 
    </javadoc>
  </target>
  <!-- Assemble the documentation -->
  <target name="docs" depends="javadocs" 
          description="Assemble the documentation" unless="docs.notRequired">
    <echo message="Assembling the documentation"/>
    <copy todir="${docs}">
      <fileset dir="${src.shared.docs}">
        <include name="*.html"/>
      </fileset>
    </copy>
    <copy todir="${docs}/stand-alone">
      <fileset dir="${src.stand-alone.docs}">
        <include name="*.html"/>
      </fileset>
    </copy>
    <copy todir="${docs}/web">
      <fileset dir="${src.web.docs}">
        <include name="*.html"/>
      </fileset>
    </copy>
  </target>
  <!-- Zip the distribution                     -->
  <!-- Zip the documentation -->
  <target name="zip-docs" depends="docs" description="Zip the documentation">
    <echo message="Zipping the documentation"/>
    <zip destfile="${dist}/${appName}-${package.docs}.zip">
      <!-- Include the documentation -->
      <fileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </fileset>
      <!-- Include the license and the README -->
      <fileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-${package.docs}.zip" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.docs}.zip" forceOverwrite="true"  
              algorithm="SHA1"/>
  </target>
  <!-- Zip the source and documentation together -->
  <target name="zip-src" depends="zip-docs" 
          description="Zip the source and documentation together">
    <echo message="Zipping the source and documentation together"/>
    <zip destfile="${dist}/${appName}-src.zip">
      <!-- Include the source code and the build files -->
      <zipfileset src="${dist}/${appName}-${package.docs}.zip"/>
      <fileset dir="${src.files.dir}">
        <patternset refid="src.files"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-src.zip" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-src.zip" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Zip the binary stand-alone distribution with the documentation -->
  <target name="zip-bin-stand-alone" depends="package-stand-alone,zip-docs" 
          description="Zip the binary stand-alone distribution 
                       with the documentation">
    <echo message="Zipping the binary stand-alone distribution with the documentation"/>
    <zip destfile="${dist}/${appName}-${package.stand-alone}-bin.zip">
      <!-- Include the documentation -->
      <zipfileset src="${dist}/${appName}-${package.docs}.zip"/>
      <!-- Include the binary JAR files -->
      <zipfileset dir="${dist}" prefix="lib">
        <patternset refid="bin.jar"/>
      </zipfileset>
      <fileset dir=".">
        <include name="${mysql.jar}"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.zip" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.zip" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Zip the binary web distribution with the documentation -->
  <target name="zip-bin-web" depends="package-web,zip-docs" 
          description="Zip the binary web distribution with the documentation">
    <echo message="Zipping the binary web distribution with the documentation"/>
    <zip destfile="${dist}/${appName}-${package.web}-bin.zip">
      <!-- Include the documentation -->
      <zipfileset src="${dist}/${appName}-${package.docs}.zip"/>
      <!-- Include the binary WAR files -->
      <fileset dir="${dist}">
        <patternset refid="bin.war"/>
      </fileset>
    </zip> 
    <checksum file="${dist}/${appName}-${package.web}-bin.zip" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.web}-bin.zip" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Zip the binary distribution with the documentation -->
  <target name="zip-bin" depends="zip-bin-stand-alone,zip-bin-web" 
          description="Zip the binary distribution with the documentation">
    <echo message="Zipping the binary distribution with the documentation"/>
    <zip destfile="${dist}/${appName}-bin.zip" 
         duplicate="preserve" update="true">
      <zipgroupfileset dir="${dist}" includes="*.zip"/>
    </zip>
    <checksum file="${dist}/${appName}-bin.zip" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-bin.zip" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Zip the binary and source distributions -->
  <target name="zip-all" depends="zip-src,zip-bin" 
          description="Zip the binary and source distributions">
    <echo message="Zipped the binary and source distributions"/>
  </target>
  <!-- Tar and gz the distribution              -->
  <!-- Tar the documentation -->
  <target name="tar-docs" depends="docs" description="Tar the documentation">
    <echo message="Tarring the documentation"/>
    <tar destfile="${dist}/${appName}-${package.docs}.tar.gz" compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
    </tar> 
    <checksum file="${dist}/${appName}-${package.docs}.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.docs}.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the source and documentation together -->
  <target name="tar-src" depends="tar-docs"
          description="Tar the documentation">
    <echo message="Tarring the documentation"/>
    <tar destfile="${dist}/${appName}-src.tar.gz" compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the source code and the build files -->
      <tarfileset dir="${src.files.dir}">
        <patternset refid="src.files"/>
      </tarfileset>
    </tar> 
    <checksum file="${dist}/${appName}-src.tar.gz" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-src.tar.gz" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Tar the binary stand-alone distribution with the documentation -->
  <target name="tar-bin-stand-alone" depends="package-stand-alone,tar-docs" 
          description="Tar the binary stand-alone distribution 
                       with the documentation">
    <echo message="Tarring the binary stand-alone distribution with the documentation"/>
    <tar destfile="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" 
         compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the binary JAR files -->
      <tarfileset dir="${dist}" prefix="lib">
        <patternset refid="bin.jar"/>
      </tarfileset>
      <tarfileset dir=".">
        <include name="${mysql.jar}"/>
      </tarfileset>    </tar> 
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the binary web distribution with the documentation -->
  <target name="tar-bin-web" depends="package-web,tar-docs" 
          description="Tar the binary web distribution with the documentation">
    <echo message="Tarring the binary web distribution with the documentation"/>
    <tar destfile="${dist}/${appName}-${package.web}-bin.tar.gz" 
         compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the binary WAR files -->
      <tarfileset dir="${dist}">
        <patternset refid="bin.war"/>
      </tarfileset>
    </tar> 
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the binary distribution with the documentation -->
  <target name="tar-bin" depends="tar-bin-stand-alone,tar-bin-web" 
          description="Tar the binary distribution with the documentation">
    <echo message="Tarring the binary distribution with the documentation"/>
    <tar destfile="${dist}/${appName}-bin.tar.gz" compression="gzip">
      <!-- Include the documentation -->
      <tarfileset dir="${docs.all.dir}">
        <patternset refid="docs.all"/>
      </tarfileset>
      <!-- Include the license and the README -->
      <tarfileset dir="${docs.misc.dir}">
        <patternset refid="docs.misc"/>
      </tarfileset>
      <!-- Include the source code and the build files -->
      <tarfileset dir="${src.files.dir}">
        <patternset refid="src.files"/>
      </tarfileset>
      <!-- Include the binary JAR files -->
      <tarfileset dir="${dist}" prefix="lib">
        <patternset refid="bin.jar"/>
      </tarfileset>
      <tarfileset dir=".">
        <include name="${mysql.jar}"/>
      </tarfileset>
      <!-- Include the binary WAR files -->
      <tarfileset dir="${dist}">
        <patternset refid="bin.war"/>
      </tarfileset>
    </tar>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Tasks that use the zip files to construct tar files -->
  <!-- Tar the binary web distribution with the documentation -->
  <target name="tar-bin-web-new" depends="package-web,tar-docs,zip-bin-web" 
          description="Tar the binary web distribution with the documentation">
    <echo message="Tarring the binary web distribution with the documentation"/>
    <unzip src="${dist}/${appName}-${package.web}-bin.zip" dest="${tmp}/web"/>
    <tar destfile="${dist}/${appName}-${package.web}-bin.tar.gz" 
         compression="gzip">
      <tarfileset dir="${tmp}/web"/>
    </tar>
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" 
              forceOverwrite="true" algorithm="SHA1"/>
  </target>
  <!-- Tar the binary distribution with the documentation -->
  <target name="tar-bin-new" 
          depends="zip-bin,tar-bin-stand-alone,tar-bin-web-new"
          description="Tar the binary distribution with the documentation">
    <echo message="Tarring the binary distribution with the documentation"/>
    <delete failonerror="false" includeemptydirs="true">
      <fileset dir="${tmp}" includes="**"/>
    </delete>
    <unzip src="${dist}/${appName}-bin.zip" dest="${tmp}"/>
    <tar destfile="${dist}/${appName}-bin.tar.gz" compression="gzip">
      <tarfileset dir="${tmp}"/>
    </tar>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true"/>
    <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true" 
              algorithm="SHA1"/>
  </target>
  <!-- Tar the binary and source distributions -->
  <target name="tar-all" depends="tar-src,tar-bin" 
          description="Tar the binary and source distributions">
    <echo message="Tarred the binary and source distributions"/>
  </target>
  <!-- Distribution targets -->
  <!-- FTP targets         -->
  <!-- Place the documentation on FTP -->
<!--
  <target name="ftp-docs" depends="zip-docs,tar-docs" 
          description="Place the documentation on FTP">
    <echo message="Placing the documentation on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.src.dir}"
         action="send">
      <fileset dir="${dist}">
        <include name="${appName}-${package.docs}.*"/>
      </fileset>
    </ftp>
  </target>
-->
  <!-- Place the documentation on FTP -->
  <target name="ftp-docs" depends="zip-docs,tar-docs" 
          description="Place the documentation on FTP">
    <echo message="Placing the documentation on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.src.dir}"
         action="send"
         newer="true"
         timediffauto="true">
      <fileset dir="${dist}">
        <include name="${appName}-${package.docs}.*"/>
      </fileset>
    </ftp>
  </target>
  <!-- Place the source code on FTP -->
  <target name="ftp-src" depends="zip-src,tar-src" 
          description="Place the source code on FTP">
    <echo message="Placing the source code on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.src.dir}"
         action="send"
         newer="true"
         timediffauto="true">
      <fileset dir="${dist}">
        <include name="${appName}-src.*"/>
      </fileset>
    </ftp>
  </target>
  <!-- Place the binaries on FTP -->
  <target name="ftp-bin" depends="zip-bin,tar-bin" 
          description="Place the binaries on FTP">
    <echo message="Placing the binaries on FTP"/>
    <ftp server="${ftp.server}"
         userid="${ftp.user}"
         password="${ftp.password}"
         remotedir="${ftp.bin.dir}"
         action="send"
         newer="true"
         timediffauto="true">
      <fileset dir="${dist}">
        <include name="${appName}*bin*"/>
      </fileset>
    </ftp>
  </target>
  <!-- Place everything on FTP -->
  <target name="ftp" description="Place everything on FTP">
    <echo message="Placing everything on FTP"/>
    <antcall target="ftp-docs"/>
    <antcall target="ftp-src"/>
    <antcall target="ftp-bin"/>
  </target>
  <!-- Place everything on FTP -->
<!--
  <target name="ftp" description="Place everything on FTP">
    <echo message="Placing everything on FTP"/>
    <input message="Please enter your username." addproperty="ftp.user"/>
    <input message="Please enter your password." addproperty="ftp.password"/>
    <splash showduration="0"/>
    <antcall target="ftp-docs"/>
    <antcall target="ftp-src"/>
    <antcall target="ftp-bin"/>
  </target>
-->
  <!-- Email targets       -->
  <!-- E-mail the documentation -->
  <target name="email-docs" depends="zip-docs,tar-docs" 
          description="E-mailing the documentation">
    <echo message="E-mailing the documentation"/>
    <mail from="${mail.from}"
          tolist="${mail.tolist}"
          mailhost="${mail.mailhost}"
          user="${mail.user}"
          password="${mail.password}"
          subject="${mail.subject}">
      <message>
        ${mail.message.docs}
      </message>
      <fileset dir="${dist}">
        <include name="${appName}-${package.docs}.*"/>
      </fileset>
    </mail>
  </target>
  <!-- Deploy the web application       -->
  <!-- 1. Copy the expanded web application -->
  <target name="deploy-copy-files" depends="copy-web" 
          description="Deploy the application by copying it to Tomcat">
    <echo message="Copying the expanded web application to CATALINA_HOME"/>
    <property environment="env"/>
    <copy todir="${build.web.web-inf}" file="${src.web.conf}/web.xml"/>
    <copy todir="${env.CATALINA_HOME}/webapps/${appName}">
      <fileset dir="${build.web.root}"/>
    </copy>
  </target>
  <!-- 2. Copy the WAR -->
  <target name="deploy-copy-war" depends="package-web" 
          description="Deploy the WAR by copying it to Tomcat">
    <echo message="Copying the WAR to CATALINA_HOME"/>
    <property environment="env"/>
    <copy file="${appName.war}" todir="${env.CATALINA_HOME}/webapps"/>
  </target>
  <!-- 3. Deploy the web application using a context XML file -->
  <target name="deploy-context" depends="copy-web" 
          description="Deploy the web application using a context XML file">
    <echo message="Deploying the web application using a context XML file"/>
    <property environment="env"/>
    <copy todir="${build.web.web-inf}" file="${src.web.conf}/web.xml"/>
    <copy todir="${env.CATALINA_HOME}/conf/Catalina/localhost" 
          file="${src.web.conf}/${appName}.xml"/>
  </target>
  <!-- The deploy task for web applications on Tomcat -->
  <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"/>
  <!-- 4. Deploy the WAR using the manager application -->
  <target name="deploy" depends="package-web" 
          description="Hot deploy the application">
    <echo message="Deploying the WAR to Tomcat"/>
    <deploy url="${manager.url}"
            username="${manager.user}"
            password="${manager.password}"  
            path="/${appName}"
            war="file:${appName.war}"
            update="true"/>
  </target>
  <!-- The undeploy task for web applications on Tomcat -->
  <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"/>
  <!-- Undeploy the web application -->
  <target name="undeploy" description="Undeploy the application">
    <echo message="Undeploying the WAR"/>
    <undeploy url="${manager.url}"
              username="${manager.user}"   
              password="${manager.password}"
              path="/${appName}"/>
  </target>
  <target name="clean" description="Clean up the working directories">
    <echo message="Cleaning up"/>
    <delete dir="${build}"/>
  </target>
</project>