<project name="Struts" default="compile.library" basedir=".">

<!--
        Struts main build.xml file for building everything related to Struts.

        This script will delegate some of it's tasks to the other build*.xml
        scripts (build-webapps.xml, build-tests.xml, ...

        For a complete list of executable tasks use -projecthelp when calling
        this build file.

-->


<!-- ========== Prerequisite Properties =================================== -->

<!--
        REQUIRED PROPERTIES

        Each of these properties MUST be set in one of the following ways:
         * on the "ant" command line
         * in a "build.properties" file in the base directory
         * in a "build.properties" file in your user home directory

        antlr.jar                     The path to the JAR file of the ANTLR
                                      package.
                                      [Version 2.7.2 or later]

        commons-beanutils.jar         The path to the JAR file of the Jakarta
                                      Commons Beanutils package.
                                      [Version 1.6.1 or later]

        commons-digester.jar          The path to the JAR file of the Jakarta
                                      Commons Digester package.
                                      [Version 1.5 or later]

        commons-fileupload.jar        The path to the JAR file of the Jakarta
                                      Commons FileUpload package.
                                      [Version 1.0 or later]

        commons-logging.jar           The path to the JAR file of the Jakarta
                                      Commons Logging package.
                                      [Version 1.0.3 or later]

        commons-validator.jar         The path to the JAR file of the Jakarta
                                      Commons Validator package.
                                      [Version 1.1.0 or later]

        jakarta-oro.jar               The path to the JAR file of the Jakarta
                                      ORO package.
                                      [Version 2.0.7 or later]

        jdbc20ext.jar                 The path to the JAR file for the JDBC 2.0
                                      Optional Package APIs.

        servlet.jar                   The path to the Servlet API classes to
                                      compile against.
                                      [Version 2.2 or 2.3]


        OPTIONAL PROPERTIES

        Each of these properties MAY be set in one of the following ways:
         * on the "ant" command line
         * in a "build.properties" file in the base directory
         * in a "build.properties" file in your user home directory
        If not set, the default, as described below, will be used instead.

        ant.jar                       The path to the ant.jar that is being
                                      used to build from this script. This is
                                      required only when executing the
                                      "generate.taglib.doc" target.

        catalina.home                 The path to the Tomcat 4.0 installation.
                                      This is required only when executing the
                                      "deploy.catalina" target.

        catalina.url                  URL of the Tomcat 4.1.x manager app for
                                      dynamic installation.

        catalina.username             Username for the Tomcat 4.1.x manager app
                                      for dynamic installation.

        catalina.password             Password for the Tomcat 4.1.x manager app
                                      for dynamic installation.

        jsp.jar                       The path to the JSP API classes to compile
                                      against, if you are using JSP 2.0, where
                                      these classes have been separated from
                                      servlet.jar. If you are using JSP 1.1 or
                                      1.2, leave this property unset.

        tomcat.home                   The path to the Tomcat 3.x installation.
                                      This is required only when executing the
                                      "deploy.tomcat" target.

        xerces.jar                    The path to the Xerces classes to copy.
                                      This is required only when executing the
                                      "deploy.catalina" target.

-->

    <!-- Load local and user build preferences -->
    <property file="build.properties"/>
    <property file="../build.properties"/>
    <property file="${user.home}/build.properties"/>

    <!-- Default values for unspecified properties -->
    <property name="catalina.home"   value="../jakarta-tomcat-4.0/build"/>
    <property name="pmd.rulesets"    value="rulesets/imports.xml,rulesets/unusedcode.xml,rulesets/basic.xml,rulesets/strings.xml"/>
    <property name="pmd.report"      value="pmdreport.html"/>

    <!--
        Location of other Struts subprojects

        These default values assume that the checked out locations are the same
        as the full repository paths, and that you are building the trunk.
    -->
    <property name="struts.el.home" value="${basedir}/contrib/el/"/>

<!-- ========== Initialization Properties ================================= -->


<!--
        These property values may optionally be overridden with property
        settings from an "ant" command line, the "build.properties" file
        in this directory, the "build.properties" file in your home
        directory, or from settings in a superior build.xml script.
-->

    <!-- Output directory name for all files generated by the build process -->
    <property name="build.home" value="${basedir}/target"/>

    <!-- Should Java compilations set the debug compiler option? -->
    <property name="compile.debug" value="true" />

    <!-- Should Java compilations set the deprecation compiler option? -->
    <property name="compile.deprecation" value="false" />

    <!-- Should Java compilations set the optimize compiler option? -->
    <property name="compile.optimize" value="true" />

    <!-- Name of the core struts library -->
    <property name="app.name" value="struts"/>

    <!-- Name of the project -->
    <property name="project.name" value="struts"/>

    <!-- Version of the project -->
    <property name="project.version" value="1.2.9"/>

<!-- ========== Derived Properties ======================================== -->


<!--
        These property values are derived from values defined above, and
        generally should NOT be overridden by command line settings
-->

    <!-- The base directory for distribution targets -->
    <property name="dist.home" value="dist" />

    <!-- The base directory for release targets -->
    <property name="release.home" value="release" />

    <!-- Source directory -->
    <property name="src.dir" value="src"/>

    <!-- Source directory for core struts library -->
    <property name="src.share.dir" value="${src.dir}/share"/>

    <!-- Source directory for non-Cactus unit tests -->
    <property name="src.test.dir" value="${src.dir}/test"/>

    <!-- Directory where core struts library configurations files are stored -->
    <property name="conf.share.dir" value="conf/share"/>

    <!-- Directory where test configurations files are stored -->
    <property name="conf.test.dir" value="conf/test"/>

    <!-- Directory where binary release files are staged -->
    <property name="stage.bin.dir" value="${release.home}/stage/bin"/>

    <!-- Directory where library release files are staged -->
    <property name="stage.lib.dir" value="${release.home}/stage/lib"/>

    <!-- Directory where source release files are staged -->
    <property name="stage.src.dir" value="${release.home}/stage/src"/>

    <!-- Directory where release builds are prepared for upload -->
    <property name="upload.dir" value="${release.home}/upload"/>

    <!-- Base file name for upload files -->
    <property name="upload.file.base" value="${project.name}-${project.version}"/>

    <!-- Doc directory -->
    <property name="doc.dir" value="doc"/>

    <!-- Web directory -->
    <property name="web.dir" value="web"/>

    <!-- This is only used if you execute "ant download-dependencies" -->
    <property name="libdir" value="${basedir}/lib" />

    <path id="downloaded.lib.classpath">
      <fileset dir="${libdir}">
        <include name="*.jar"/>
      </fileset>
    </path>


    <!-- Compilation Classpath -->
    <path id="compile.classpath">
      <pathelement location="${commons-beanutils.jar}"/>
      <pathelement location="${commons-digester.jar}"/>
      <pathelement location="${commons-fileupload.jar}"/>
      <pathelement location="${commons-logging.jar}"/>
      <pathelement location="${commons-validator.jar}"/>
      <pathelement location="${jakarta-oro.jar}"/>
      <pathelement location="${jdbc20ext.jar}"/>
      <pathelement location="${jsp.jar}"/>
      <pathelement location="${servlet.jar}"/>
      <pathelement location="${antlr.jar}"/>
      <pathelement location="${xerces.jar}"/>

      <!-- this is harmless if not used -->
      <path refid="downloaded.lib.classpath"/>

    </path>

    <!-- PMD Classpath -->

    <path id="pmd.classpath">
      <fileset dir="${pmd.home}/lib">
        <include name="*.jar"/>
      </fileset>
    </path>

<!-- ========== Executable Targets ======================================== -->


<!--
        The "init" target evaluates "available" expressions as necessary
        to modify the behavior of this script and print some information on
        screen
-->
    <target name="init">

        <echo message="--------- ${project.name} ${project.version} ---------"/>
        <echo message=""/>

        <echo message="java.class.path = ${java.class.path}"/>
        <echo message="java.home = ${java.home}"/>
        <echo message="user.home = ${user.home}"/>

        <filter  token="version" value="${project.version}"/>

        <tstamp>
            <format property="year" pattern="yyyy"/>
        </tstamp>
    </target>

    <target name="download-dependencies">

    <!--
      To use this Maven-like freedom with respect to dependency setup,
      do the following:

      - run ant as you normally would, but add the following target to the command
        line:

        download-dependencies

          For example:
             C:>myproject\ant download-dependencies dist


    -->

        <mkdir dir="${libdir}"/>

        <get dest="${libdir}/commons-beanutils.jar"
            usetimestamp="true" ignoreerrors="true"
            src="http://www.ibiblio.org/maven/commons-beanutils/jars/commons-beanutils-1.7.0.jar"/>

        <get dest="${libdir}/commons-digester.jar"
            usetimestamp="true" ignoreerrors="true"
            src="http://www.ibiblio.org/maven/commons-digester/jars/commons-digester-1.6.jar"/>

        <get dest="${libdir}/commons-fileupload.jar"
            usetimestamp="true" ignoreerrors="true"
            src="http://www.ibiblio.org/maven/commons-fileupload/jars/commons-fileupload-1.0.jar"/>

        <get dest="${libdir}/commons-logging.jar"
            usetimestamp="true" ignoreerrors="true"
            src="http://www.ibiblio.org/maven/commons-logging/jars/commons-logging-1.0.4.jar"/>

        <get dest="${libdir}/commons-validator.jar"
            usetimestamp="true" ignoreerrors="true"
            src="http://www.ibiblio.org/maven/commons-validator/jars/commons-validator-1.1.4.jar"/>

        <get dest="${libdir}/jakarta-oro.jar"
            usetimestamp="true" ignoreerrors="true"
            src="http://www.ibiblio.org/maven/oro/jars/oro-2.0.7.jar"/>

        <get dest="${libdir}/xerces.jar"
            usetimestamp="true" ignoreerrors="true"
            src="http://www.ibiblio.org/maven/xml-apis/jars/xml-apis-2.0.2.jar"/>

        <get dest="${libdir}/antlr.jar"
            usetimestamp="true" ignoreerrors="true"
            src="http://www.ibiblio.org/maven/antlr/jars/antlr-2.7.2.jar"/>

        <get dest="${libdir}/servlet.jar"
            usetimestamp="true" ignoreerrors="true"
            src="http://www.ibiblio.org/maven/servletapi/jars/servletapi-2.2.jar"/>

        <get dest="${libdir}/jstl-1.0.6.jar"
            usetimestamp="true" ignoreerrors="true"
            src="http://www.ibiblio.org/maven/jstl/jars/jstl-1.0.6.jar"/>

        <get dest="${libdir}/standard-1.0.6.jar"
            usetimestamp="true" ignoreerrors="true"
            src="http://www.ibiblio.org/maven/taglibs/jars/standard-1.0.6.jar"/>

        <get dest="${libdir}/junit-3.8.1.jar"
            usetimestamp="true" ignoreerrors="true"
            src="http://www.ibiblio.org/maven/junit/jars/junit-3.8.1.jar"/>

        <property name="commons-beanutils.jar"  value="${libdir}/commons-beanutils.jar"/>
        <property name="commons-digester.jar"   value="${libdir}/commons-digester.jar"/>
        <property name="commons-fileupload.jar" value="${libdir}/commons-fileupload.jar"/>
        <property name="commons-logging.jar"    value="${libdir}/commons-logging.jar"/>
        <property name="commons-validator.jar"  value="${libdir}/commons-validator.jar"/>
        <property name="jakarta-oro.jar"        value="${libdir}/jakarta-oro.jar"/>
        <property name="xerces.jar"             value="${libdir}/xerces.jar"/>
        <property name="antlr.jar"              value="${libdir}/antlr.jar"/>
        <property name="servlet.jar"            value="${libdir}/servlet.jar"/>
        <property name="jstl.jar"               value="${libdir}/jstl-1.0.6.jar"/>
        <property name="jstl-standard.jar"      value="${libdir}/standard-1.0.6.jar"/>
        <property name="junit.jar"              value="${libdir}/junit-3.8.1.jar"/>


    </target>

<!--
        Create directories and copy files for the core struts library
-->
    <target name="prepare.library" depends="init">
        <mkdir dir="${build.home}/library/classes/META-INF"/>
        <mkdir dir="${build.home}/library/classes/META-INF/tlds"/>
        <mkdir dir="${build.home}/library/classes/org/apache/struts/resources"/>
        <copy file="LICENSE.txt"
            tofile="${build.home}/library/classes/META-INF/LICENSE"/>
        <copy file="NOTICE.txt"
            tofile="${build.home}/library/classes/META-INF/NOTICE"/>
        <copy todir="${build.home}/library/classes/org/apache/struts/resources">
            <fileset dir="${conf.share.dir}" includes="**/*.dtd"/>
        </copy>
        <copy  todir="${build.home}/conf" filtering="on">
             <fileset dir="${conf.share.dir}" includes="*.MF"/>
        </copy>

        <copy file="${commons-beanutils.jar}"
            tofile="${build.home}/library/commons-beanutils.jar"/>
        <copy file="${commons-digester.jar}"
            tofile="${build.home}/library/commons-digester.jar"/>
        <copy file="${commons-fileupload.jar}"
            tofile="${build.home}/library/commons-fileupload.jar"/>
        <copy file="${commons-logging.jar}"
            tofile="${build.home}/library/commons-logging.jar"/>
        <copy file="${commons-validator.jar}"
            tofile="${build.home}/library/commons-validator.jar"/>
        <copy file="${jakarta-oro.jar}"
            tofile="${build.home}/library/jakarta-oro.jar"/>
        <copy file="${antlr.jar}" failonerror="false"
            tofile="${build.home}/library/antlr.jar"/>
<!-- Compile-time dependency only
        <copy file="${jdbc20ext.jar}"
            tofile="${build.home}/library/jdbc2_0-stdext.jar"/>

-->
    </target>

<!--
        Prepare static directories for web applications
-->
    <target name="static.webapps">
        <ant antfile="build-webapps.xml" target="static"/>
    </target>

<!--
        Compile core struts library directory components
-->
    <target name="compile.library" depends="prepare.library"
     description="Compile Struts library files">
        <javac srcdir="${src.share.dir}"
            destdir="${build.home}/library/classes"
            debug="${compile.debug}"
            optimize="${compile.optimize}"
            deprecation="${compile.deprecation}">
          <classpath refid="compile.classpath"/>
        </javac>
        <copy todir="${build.home}/library/classes">
            <fileset dir="${src.share.dir}" includes="**/*.properties"/>
        </copy>
        <copy todir="${build.home}/library">
            <fileset dir="${conf.share.dir}" includes="*.dtd"/>
            <fileset dir="${conf.share.dir}" includes="*.tld"/>
            <fileset dir="${conf.share.dir}" includes="*.xml"/>
        </copy>
        <style basedir="${doc.dir}/userGuide"
            destdir="${build.home}/library"
            extension=".tld"
            style="${doc.dir}/stylesheets/tld.xsl"
            includes="struts-*.xml"/>
        <copy todir="${build.home}/library/classes/META-INF/tlds">
            <fileset dir="${build.home}/library" includes="struts-*.tld"/>
        </copy>
        <copy todir="${build.home}/library/classes/META-INF/tlds" overwrite="true">
            <fileset dir="${build.home}/library" includes="struts-*.tld"/>
            <mapper type="regexp" from="^(.*)\.tld$$" to="\1-1.1.tld"/>
        </copy>
        <replace dir="${build.home}/library/classes/META-INF/tlds" >
            <include name="*-1.1.tld"/>
            <replacefilter token="http://struts.apache.org/tags"
                           value="http://jakarta.apache.org/struts/tags"/>
        </replace>
        <jar jarfile="${build.home}/library/${app.name}.jar"
            manifest="${build.home}/conf/MANIFEST.MF"
            basedir="${build.home}/library/classes"
            includes="**"/>
    </target>

<!--
        Compile code for web applications
-->
    <target name="compile.webapps" depends="compile.library,static.webapps"
     description="Compile Struts web applications">
        <ant antfile="build-webapps.xml" target="compile"/>
    </target>

<!--
        Create Javadoc documentation
-->
    <target name="compile.javadoc"
     description="Generate JavaDoc API docs">
        <delete dir="${build.home}/documentation/api"/>
        <mkdir dir="${build.home}/documentation/api"/>
        <javadoc sourcepath="${src.share.dir}"
            destdir="${build.home}/documentation/api"
            classpath="${servlet.jar}:${jsp.jar}:${jdbc20ext.jar}"
            packagenames="org.apache.struts.*"
            author="true"
            private="true"
            use="true"
            version="true"
            windowtitle="Apache Struts API Documentation"
            doctitle="&lt;h1&gt;Apache Struts Framework (Version ${project.version})&lt;/h1&gt;"
            bottom="Copyright &#169; 2000-${year} - The Apache Software Foundation">
            <classpath refid="compile.classpath"/>
        </javadoc>
    </target>

<!--
        Generate new taglib JavaDoc-like documentation
-->
    <target name="generate-reports" if="ant.jar">
        <mkdir  dir="${dist.home}/contrib"/>
        <ant    dir="${basedir}/contrib/tag-doc"
             target="clean" inheritAll="false"/>
        <ant    dir="${basedir}/contrib/tag-doc"
             target="dist" inheritAll="true"/>
        <ant    dir="${basedir}/contrib/tag-doc"
             target="generate-reports" inheritAll="false"/>
        <mkdir  dir="${dist.home}/contrib/tag-doc"/>
        <copy todir="${dist.home}/contrib/tag-doc">
           <fileset dir="${basedir}/contrib/tag-doc/target"/>
        </copy>

    </target>


<!--
        Create directories and copy files for distribution
-->
    <target name="prepare.dist" depends="init">
        <mkdir dir="${dist.home}"/>
        <mkdir dir="${dist.home}/lib"/>
        <mkdir dir="${dist.home}/webapps"/>
    </target>

<!--
        Construct library distributables
-->
    <target name="dist.library" depends="prepare.dist,compile.library">
        <copy todir="${dist.home}/lib">
            <fileset dir="${build.home}/library" includes="*.dtd"/>
            <fileset dir="${build.home}/library" includes="*.jar"/>
            <fileset dir="${build.home}/library" includes="*.tld"/>
            <fileset dir="${build.home}/library" includes="*.xml"/>
        </copy>
    </target>

<!--
        Construct distributable web applications
-->
    <target name="dist.webapps" depends="compile.webapps,compile.javadoc">
        <ant antfile="build-webapps.xml" target="dist"/>
    </target>

<!--
        Copy sources for distribution
-->
    <target name="dist.source" depends="prepare.dist">
        <copy file="INSTALL" tofile="${dist.home}/INSTALL"/>
        <copy file="LICENSE.txt" tofile="${dist.home}/LICENSE"/>
        <copy file="NOTICE.txt" tofile="${dist.home}/NOTICE"/>
        <copy file="README" tofile="${dist.home}/README"/>
    </target>


<!--
        Build the contrib modules that are packaged with the binary
-->
    <target name="dist.contrib" depends="dist.source" if="jstl.jar">

        <mkdir  dir="${dist.home}/contrib"/>

    <!-- The STRUTS-EL Tag Library  -->

        <ant    dir="${struts.el.home}"
             target="clean" inheritAll="false"/>
        <ant    dir="${struts.el.home}"
             target="dist" inheritAll="false"/>
        <mkdir  dir="${dist.home}/contrib/struts-el"/>
        <copy todir="${dist.home}/contrib/struts-el">
           <fileset dir="${struts.el.home}/dist"/>
        </copy>
    </target>


<!--
        Build the example standalone modules (even though not yet included)
-->
    <target name="dist.examples" depends="dist.library">

      <!-- The Mail Reader Database APIs -->
      <ant    dir="${basedir}/struts-examples/mailreader"
           target="clean" inheritAll="false"/>
      <ant    dir="${basedir}/struts-examples/mailreader"
           target="dist" inheritAll="false"/>

    </target>

<!--
        Construct complete binary distribution
-->
    <target name="dist"
         depends="dist.library,dist.webapps,dist.source,dist.contrib,dist.examples"
     description="Construct binary distribution"/>

<!--
        Construct the nightly build
-->
    <target name="nightly">
      <tstamp>
                 <format property="TODAY" pattern="yyyyMMdd" locale="en"/>
      </tstamp>
      <antcall target="release">
        <param name="upload.file.base" value="${project.name}-SNAPSHOT-${TODAY}"/>
      </antcall>
    </target>


<!--
        Construct complete release distributions
-->
    <target name="release" depends="clean,dist"
    description="Construct release distribution">
        <mkdir dir="${stage.bin.dir}/${upload.file.base}-bin"/>
        <mkdir dir="${stage.lib.dir}/${upload.file.base}-lib"/>
        <mkdir dir="${stage.src.dir}/${upload.file.base}-src"/>
        <copy todir="${stage.bin.dir}/${upload.file.base}-bin">
            <fileset dir="${dist.home}"/>
        </copy>
        <copy todir="${stage.lib.dir}/${upload.file.base}-lib">
            <fileset dir="${dist.home}" includes="LICENSE NOTICE"/>
            <fileset dir="${dist.home}/lib"/>
        </copy>
        <copy todir="${stage.src.dir}/${upload.file.base}-src">
            <fileset dir=".">
                <exclude name="build.properties"/>
                <exclude name="target/**"/>
                <exclude name="dist/**"/>
                <exclude name="release/**"/>
                <exclude name="lib/**"/>
            </fileset>
        </copy>

        <!-- struts-el source -->
        <mkdir dir="${stage.src.dir}/${upload.file.base}-src/contrib"/>
        <mkdir dir="${stage.src.dir}/${upload.file.base}-src/contrib/struts-el"/>
        <copy todir="${stage.src.dir}/${upload.file.base}-src/contrib/struts-el">
            <fileset dir="${struts.el.home}">
                <exclude name="build.properties"/>
                <exclude name="target/**"/>
                <exclude name="dist/**"/>
                <exclude name="release/**"/>
            </fileset>
        </copy>

        <!-- delete duplicate "el" directory -->
        <delete dir="${stage.src.dir}/${upload.file.base}-src/contrib/el"/>

        <mkdir dir="${upload.dir}"/>
        <zip  zipfile="${upload.dir}/${upload.file.base}-bin.zip"
              basedir="${stage.bin.dir}"/>
        <zip  zipfile="${upload.dir}/${upload.file.base}-lib.zip"
              basedir="${stage.lib.dir}"/>
        <zip  zipfile="${upload.dir}/${upload.file.base}-src.zip"
              basedir="${stage.src.dir}"/>
        <tar  tarfile="${upload.dir}/${upload.file.base}-bin.tar"
              basedir="${stage.bin.dir}"
             longfile="gnu"/>
        <tar  tarfile="${upload.dir}/${upload.file.base}-lib.tar"
              basedir="${stage.lib.dir}"
             longfile="gnu"/>
        <tar  tarfile="${upload.dir}/${upload.file.base}-src.tar"
              basedir="${stage.src.dir}"
             longfile="gnu"/>
        <gzip     src="${upload.dir}/${upload.file.base}-bin.tar"
              zipfile="${upload.dir}/${upload.file.base}-bin.tar.gz"/>
        <gzip     src="${upload.dir}/${upload.file.base}-lib.tar"
              zipfile="${upload.dir}/${upload.file.base}-lib.tar.gz"/>
        <gzip     src="${upload.dir}/${upload.file.base}-src.tar"
              zipfile="${upload.dir}/${upload.file.base}-src.tar.gz"/>
        <delete>
            <fileset dir="${upload.dir}" includes="*.tar"/>
        </delete>
        <checksum algorithm="MD5" fileext=".md5">
            <fileset dir="${upload.dir}" includes="*.zip,*.gz"/>
        </checksum>
    </target>

<!--
        Deploy these applications on Catalina
-->
    <target name="deploy.catalina" depends="compile.webapps"
     description="Deploy Struts web.apps in Catalina (Tomcat 4.0)">

        <mkdir dir="${catalina.home}/webapps/struts-blank"/>
        <copy todir="${catalina.home}/webapps/struts-blank">
            <fileset dir="${build.home}/blank"/>
        </copy>

        <mkdir dir="${catalina.home}/webapps/struts-documentation"/>
        <copy todir="${catalina.home}/webapps/struts-documentation">
            <fileset dir="${build.home}/documentation"/>
        </copy>

        <mkdir dir="${catalina.home}/webapps/struts-example"/>
        <copy todir="${catalina.home}/webapps/struts-example">
            <fileset dir="${build.home}/example"/>
        </copy>

        <mkdir dir="${catalina.home}/webapps/struts-examples"/>
        <copy todir="${catalina.home}/webapps/struts-examples">
            <fileset dir="${build.home}/examples"/>
        </copy>

    </target>


<!--
        Dynamic struts-documentation management on Catalina (Tomcat 4.1.x required)
-->

    <target name="install.documentation" depends="compile.webapps"
     description="Dynamically install struts-documentation on Catalina (Tomcat 4.1)">
      <taskdef name="install" classname="org.apache.catalina.ant.InstallTask"/>
      <install url="${catalina.url}" username="${catalina.username}"
       password="${catalina.password}" path="/struts-documentation"
            war="file://${build.home}/documentation"/>
    </target>

    <target name="reload.documentation" depends="compile.webapps"
     description="Dynamically reload struts-documentation on Catalina (Tomcat 4.1)">
      <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"/>
      <reload url="${catalina.url}" username="${catalina.username}"
       password="${catalina.password}" path="/struts-documentation"/>
    </target>

    <target name="remove.documentation"
     description="Dynamically remove struts-documentation on Catalina (Tomcat 4.1)">
      <taskdef name="remove" classname="org.apache.catalina.ant.RemoveTask"/>
      <remove url="${catalina.url}" username="${catalina.username}"
       password="${catalina.password}" path="/struts-documentation"/>
    </target>


<!--
        Dynamic struts-example management on Catalina (Tomcat 4.1.x required)
-->

    <target name="install.example" depends="compile.webapps"
     description="Dynamically install struts-example on Catalina (Tomcat 4.1)">
      <taskdef name="install" classname="org.apache.catalina.ant.InstallTask"/>
      <install url="${catalina.url}" username="${catalina.username}"
       password="${catalina.password}" path="/struts-example"
            war="file://${build.home}/example"/>
    </target>

    <target name="list.catalina"
     description="Dynamically list installed apps on Catalina (Tomcat 4.1)">
      <taskdef name="list"   classname="org.apache.catalina.ant.ListTask"/>
      <list url="${catalina.url}" username="${catalina.username}"
       password="${catalina.password}"/>
    </target>

    <target name="reload.example" depends="compile.webapps"
     description="Dynamically reload struts-example on Catalina (Tomcat 4.1)">
      <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"/>
      <reload url="${catalina.url}" username="${catalina.username}"
       password="${catalina.password}" path="/struts-example"/>
    </target>

    <target name="remove.example"
     description="Dynamically remove struts-example on Catalina (Tomcat 4.1)">
      <taskdef name="remove" classname="org.apache.catalina.ant.RemoveTask"/>
      <remove url="${catalina.url}" username="${catalina.username}"
       password="${catalina.password}" path="/struts-example"/>
    </target>

    <!-- Backwards Compatibility -->
    <target name="install.catalina" depends="install.example"/>
    <target name="reload.catalina" depends="reload.example"/>
    <target name="remove.catalina" depends="remove.example"/>


<!--
        Dynamic struts-exercise management on Catalina (Tomcat 4.1.x required)
-->

    <target name="install.exercise" depends="compile.webapps"
     description="Dynamically install struts-exercise on Catalina (Tomcat 4.1)">
      <taskdef name="install" classname="org.apache.catalina.ant.InstallTask"/>
      <install url="${catalina.url}" username="${catalina.username}"
       password="${catalina.password}" path="/struts-exercise"
            war="file://${build.home}/exercise-taglib"/>
    </target>

    <target name="reload.exercise" depends="compile.webapps"
     description="Dynamically reload struts-exercise on Catalina (Tomcat 4.1)">
      <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"/>
      <reload url="${catalina.url}" username="${catalina.username}"
       password="${catalina.password}" path="/struts-exercise"/>
    </target>

    <target name="remove.exercise"
     description="Dynamically remove struts-exercise on Catalina (Tomcat 4.1)">
      <taskdef name="remove" classname="org.apache.catalina.ant.RemoveTask"/>
      <remove url="${catalina.url}" username="${catalina.username}"
       password="${catalina.password}" path="/struts-exercise"/>
    </target>


<!--
        Dynamic struts-tiles management on Catalina (Tomcat 4.1.x required)
-->

    <target name="install.tiles" depends="compile.webapps"
     description="Dynamically install struts-tiles on Catalina (Tomcat 4.1)">
      <taskdef name="install" classname="org.apache.catalina.ant.InstallTask"/>
      <install url="${catalina.url}" username="${catalina.username}"
       password="${catalina.password}" path="/struts-tiles"
            war="file://${build.home}/tiles-documentation"/>
    </target>

    <target name="reload.tiles" depends="compile.webapps"
     description="Dynamically reload struts-tiles on Catalina (Tomcat 4.1)">
      <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"/>
      <reload url="${catalina.url}" username="${catalina.username}"
       password="${catalina.password}" path="/struts-tiles"/>
    </target>

    <target name="remove.tiles"
     description="Dynamically remove struts-tiles on Catalina (Tomcat 4.1)">
      <taskdef name="remove" classname="org.apache.catalina.ant.RemoveTask"/>
      <remove url="${catalina.url}" username="${catalina.username}"
       password="${catalina.password}" path="/struts-tiles"/>
    </target>


<!--
        Dynamic struts-upload management on Catalina (Tomcat 4.1.x required)
-->

    <target name="install.upload" depends="compile.webapps"
     description="Dynamically install struts-upload on Catalina (Tomcat 4.1)">
      <taskdef name="install" classname="org.apache.catalina.ant.InstallTask"/>
      <install url="${catalina.url}" username="${catalina.username}"
       password="${catalina.password}" path="/struts-upload"
            war="file://${build.home}/upload"/>
    </target>

    <target name="reload.upload" depends="compile.webapps"
     description="Dynamically reload struts-upload on Catalina (Tomcat 4.1)">
      <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"/>
      <reload url="${catalina.url}" username="${catalina.username}"
       password="${catalina.password}" path="/struts-upload"/>
    </target>

    <target name="remove.upload"
     description="Dynamically remove struts-upload on Catalina (Tomcat 4.1)">
      <taskdef name="remove" classname="org.apache.catalina.ant.RemoveTask"/>
      <remove url="${catalina.url}" username="${catalina.username}"
       password="${catalina.password}" path="/struts-upload"/>
    </target>


<!--
        Dynamic struts-tiles management on Catalina (Tomcat 4.1.x required)
-->

    <target name="install.validator" depends="compile.webapps"
     description="Dynamically install struts-validator on Catalina (Tomcat 4.1)">
      <taskdef name="install" classname="org.apache.catalina.ant.InstallTask"/>
      <install url="${catalina.url}" username="${catalina.username}"
       password="${catalina.password}" path="/struts-validator"
            war="file://${build.home}/validator"/>
    </target>

    <target name="reload.validator" depends="compile.webapps"
     description="Dynamically reload struts-validator on Catalina (Tomcat 4.1)">
      <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"/>
      <reload url="${catalina.url}" username="${catalina.username}"
       password="${catalina.password}" path="/struts-validator"/>
    </target>

    <target name="remove.validator"
     description="Dynamically remove struts-validator on Catalina (Tomcat 4.1)">
      <taskdef name="remove" classname="org.apache.catalina.ant.RemoveTask"/>
      <remove url="${catalina.url}" username="${catalina.username}"
       password="${catalina.password}" path="/struts-validator"/>
    </target>


<!--
        Deploy these applications on Tomcat
-->
    <target name="deploy.tomcat" depends="compile.webapps"
     description="Deploy Struts web.apps in Tomcat 3.x">

        <mkdir dir="${tomcat.home}/webapps/struts-blank"/>
        <copy todir="${tomcat.home}/webapps/struts-blank">
            <fileset dir="${build.home}/blank"/>
        </copy>

        <mkdir dir="${tomcat.home}/webapps/struts-documentation"/>
        <copy todir="${tomcat.home}/webapps/struts-documentation">
            <fileset dir="${build.home}/documentation"/>
        </copy>

        <mkdir dir="${tomcat.home}/webapps/struts-example"/>
        <copy todir="${tomcat.home}/webapps/struts-example">
            <fileset dir="${build.home}/example"/>
        </copy>

        <mkdir dir="${tomcat.home}/webapps/struts-exercise-taglib"/>
        <copy todir="${tomcat.home}/webapps/struts-exercise-taglib">
            <fileset dir="${build.home}/exercise-taglib"/>
        </copy>

        <mkdir dir="${tomcat.home}/webapps/struts-upload"/>
        <copy todir="${tomcat.home}/webapps/struts-upload">
            <fileset dir="${build.home}/upload"/>
        </copy>

    </target>

<!--
       Clean contrib distribution
-->
    <target name="clean.contrib" >
        <ant dir="${struts.el.home}"
             target="clean" inheritAll="false"/>
     </target>

<!--
        Clean up build and distribution directories
-->
    <target name="clean" depends="clean.contrib"
     description="Clean build and distribution directories">
        <delete dir="${build.home}"/>
        <delete dir="${dist.home}"/>
        <delete dir="${release.home}"/>
        <ant    dir="${basedir}/struts-examples/mailreader"
             target="clean" inheritAll="false"/>
    </target>

<!--
        Clean up build and distribution directories, then remove the downloaded dependencies directory
-->
    <target name="clean-lib" depends="clean"
     description="Clean the downloaded libs (you only run this if you also use 'download-dependencies' target)">
        <delete dir="${libdir}"/>
    </target>

<!--
        All-in-one build target
-->
    <target name="all" depends="clean,compile.library,compile.webapps"
     description="Clean and build library and web applications"/>


<!--
        Source code analysis targets
-->
    <target name="checkstyle" if="checkstyle.jar"
            description="Checks source code against Sun coding guidelines"
            depends="init">
        <taskdef name="checkstyle"
                 classname="com.puppycrawl.tools.checkstyle.CheckStyleTask">
            <classpath location="${checkstyle.jar}"/>
        </taskdef>
        <checkstyle>
            <formatter type="plain"/>
            <fileset dir="${src.share.dir}" includes="**/*.java"/>
        </checkstyle>
    </target>

    <target name="pmd" if="pmd.home"
            description="Locates unused imports, unused variables, etc."
            depends="init">
        <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask">
            <classpath refid="pmd.classpath"/>
        </taskdef>
        <pmd printToConsole="true" rulesetfiles="${pmd.rulesets}" shortFilenames="true">
            <formatter type="html" toFile="${pmd.report}"  />
            <fileset dir="${src.share.dir}" includes="**/*.java"/>
        </pmd>
    </target>

    <target name="findbugs" if="findbugs.home"
            description="Detects bugs using well-known patterns"
            depends="init">
        <taskdef name="findbugs"
                 classname="edu.umd.cs.findbugs.anttask.FindBugsTask" >
            <classpath location="${findbugs.home}/lib/findbugs-ant.jar"/>
        </taskdef>
        <findbugs home="${findbugs.home}"
                  output="xml"
                  outputFile="${build.home}/findbugs.xml">
            <class location="${build.home}/library/classes"/>
            <auxClasspath>
                <path refid="compile.classpath"/>
            </auxClasspath>
            <sourcePath path="${src.share.dir}"/>
      </findbugs>
  </target>


<!--
        Compile Website documenation
-->

<target name="clean.website" depends="clean,compile.website"/>
<target name="compile.website"
        description="Compile main website">
        <ant antfile="build-webapps.xml" target="compile.docs"/>
        <ant antfile="build-webapps.xml" target="validate.docs"/>
</target>


<!--
        Run tests on all servers not commented out in the build.properties file.
-->

    <!-- =================== Cactus-Based Tests on Tomcat ================= -->


    <target name="test.tomcat.all"
         depends="skip.tomcat.32,test.tomcat.32,
                  skip.tomcat.33,test.tomcat.33,
                  skip.tomcat.40,test.tomcat.40,
                  skip.tomcat.41,test.tomcat.41"
     description="Run Cactus-based unit tests on all servlet engines">
    </target>

    <target name="skip.tomcat.32" unless="tomcat.home.32">
        <echo message="*****************************************************"/>
        <echo message="WARNING : Property 'tomcat.home.32' has not been set."/>
        <echo message="          No test will be run on that servlet engine."/>
        <echo message="*****************************************************"/>
        <echo message=""/>
    </target>

    <target name="test.tomcat.32" if="tomcat.home.32"
         depends="skip.tomcat.32,compile.library"
     description="Run Cactus-based unit tests on Tomcat 3.2">
        <echo message="tomcat.home.32 = ${tomcat.home.32}"/>
        <ant antfile="build-tests.xml" target="test.tomcat.32"/>
        <echo message="test.tomcat.32 complete using ${cactus.home}"/>
    </target>


    <target name="skip.tomcat.33" unless="tomcat.home.33">
        <echo message="*****************************************************"/>
        <echo message="WARNING : Property 'tomcat.home.33' has not been set."/>
        <echo message="          No test will be run on that servlet engine."/>
        <echo message="*****************************************************"/>
        <echo message=""/>
    </target>

    <target name="test.tomcat.33" if="tomcat.home.33"
         depends="skip.tomcat.33,compile.library"
     description="Run Cactus-based unit tests on Tomcat 3.3">
        <echo message="tomcat.home.33 = ${tomcat.home.33}"/>
        <ant antfile="build-tests.xml" target="test.tomcat.33"/>
        <echo message="test.tomcat.33 complete using ${cactus.home}"/>
    </target>

    <target name="skip.tomcat.40" unless="tomcat.home.40">
        <echo message="*****************************************************"/>
        <echo message="WARNING : Property 'tomcat.home.40' has not been set."/>
        <echo message="          No test will be run on that servlet engine."/>
        <echo message="*****************************************************"/>
        <echo message=""/>
    </target>

    <target name="test.tomcat.40" if="tomcat.home.40"
         depends="skip.tomcat.40,compile.library"
     description="Run Cactus-based unit tests on Tomcat 4.0">
        <echo message="tomcat.home.40 = ${tomcat.home.40}"/>
        <ant antfile="build-tests.xml" target="test.tomcat.40"/>
        <echo message="test.tomcat.40 complete using ${cactus.home}"/>
    </target>


    <target name="skip.tomcat.41" unless="tomcat.home.41">
        <echo message="*****************************************************"/>
        <echo message="WARNING : Property 'tomcat.home.41' has not been set."/>
        <echo message="          No test will be run on that servlet engine."/>
        <echo message="*****************************************************"/>
        <echo message=""/>
    </target>

    <target name="test.tomcat.41" if="tomcat.home.41"
         depends="skip.tomcat.41,compile.library"
     description="Run unit tests on Tomcat 4.1">
        <echo message="tomcat.home.41 = ${tomcat.home.41}"/>
        <ant antfile="build-tests.xml" target="test.tomcat.41"/>
        <echo message="test.tomcat.41 complete using ${cactus.home}"/>
    </target>


    <target name="skip.tomcat.50" unless="tomcat.home.50">
        <echo message="*****************************************************"/>
        <echo message="WARNING : Property 'tomcat.home.50' has not been set."/>
        <echo message="          No test will be run on that servlet engine."/>
        <echo message="*****************************************************"/>
        <echo message=""/>
    </target>

    <target name="test.tomcat.50" if="tomcat.home.50"
         depends="skip.tomcat.50,compile.library"
     description="Run unit tests on Tomcat 5.0">
        <echo message="tomcat.home.50 = ${tomcat.home.50}"/>
        <ant antfile="build-tests.xml" target="test.tomcat.50"/>
        <echo message="test.tomcat.50 complete using ${cactus.home}"/>
    </target>


    <!-- ========== Non-Cactus Unit Tests ================================= -->

    <target name="test.junit" depends="compile.library"
     description="Run non-Cactus JUnit tests">
      <ant antfile="build-tests.xml" target="test.junit"/>
    </target>


</project>
