<?xml version="1.0"?>
<!--
 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.
-->
<project name="Tomcat 6.0" default="release" basedir=".">


  <!-- ===================== Initialize Property Values =================== -->

  <!-- We read customizable properties from the file "build.properties.default" -->
  <!-- and also from "build.properties" if it exists.                           -->
  <!-- The values in "build.properties" have stronger preference.               -->
  <!-- If you want to customize your build, you can either change the values    -->
  <!-- directly in the default file, or create a new build.properties and set   -->
  <!-- the values there. This way you don't have to change a file which is part -->
  <!-- of the original project source code.                                     -->
  <!-- See "build.properties.default" in the top level directory for some       -->
  <!-- property values you may customize.                                       -->
  <property file="${user.home}/build.properties"/>
  <property file="build.properties"/>

  <property file="build.properties.default"/>

  <!-- Project Properties -->
  <property name="project"               value="apache-tomcat" />
  <property name="name"                  value="Apache Tomcat" />
  <tstamp>
    <format property="year" pattern="yyyy" locale="en"/>
  </tstamp>
  <property name="version.major"         value="6" />
  <property name="version.minor"         value="0" />
  <property name="version.build"         value="0" />
  <property name="version.patch"         value="0" />
  <property name="version.suffix"        value="-dev" />

  <property name="version"               value="${version.major}.${version.minor}.${version.build}${version.suffix}" />
  <property name="version.number"        value="${version.major}.${version.minor}.${version.build}.${version.patch}" />
  <property name="version.major.minor"   value="${version.major}.${version.minor}" />

  <property name="final.name"            value="${project}-${version}" />
  <property name="final-src.name"        value="${project}-${version}-src" />

  <!-- Build Defaults -->
  <property name="tomcat.build"      value="${basedir}/output/build"/>
  <property name="tomcat.classes"    value="${basedir}/output/classes"/>
  <property name="tomcat.dist"       value="${basedir}/output/dist"/>
  <property name="tomcat.deployer"   value="${basedir}/output/deployer"/>
  <property name="tomcat.extras"     value="${basedir}/output/extras"/>
  <property name="tomcat.release"    value="${basedir}/output/release"/>
  <property name="test.failonerror"  value="true"/>
  <property name="test.runner"       value="junit.textui.TestRunner"/>

  <!-- constant to declare a file binary for md5sum -->
  <property name="md5sum.binary-prefix" value=" *" />

  <!-- Can't be lower - jsp uses templates -->
  <property name="compile.source" value="1.5"/>

  <!-- JAR artifacts -->
  <property name="bootstrap.jar" value="${tomcat.build}/bin/bootstrap.jar"/>

  <property name="annotations-api.jar" value="${tomcat.build}/lib/annotations-api.jar"/>
  <property name="servlet-api.jar" value="${tomcat.build}/lib/servlet-api.jar"/>
  <property name="jsp-api.jar" value="${tomcat.build}/lib/jsp-api.jar"/>
  <property name="el-api.jar" value="${tomcat.build}/lib/el-api.jar"/>
  <property name="catalina.jar" value="${tomcat.build}/lib/catalina.jar"/>
  <property name="catalina-ant.jar" value="${tomcat.build}/lib/catalina-ant.jar"/>
  <property name="tomcat-coyote.jar" value="${tomcat.build}/lib/tomcat-coyote.jar"/>

  <property name="jasper.jar" value="${tomcat.build}/lib/jasper.jar"/>
  <property name="jasper-el.jar" value="${tomcat.build}/lib/jasper-el.jar"/>

  <property name="tomcat-dbcp.home" value="${base.path}/tomcat${version.major}-deps/dbcp" />
  <property name="tomcat-dbcp.jar" value="${tomcat-dbcp.home}/tomcat-dbcp.jar"/>

  <!-- Version info filter set -->
  <filterset id="version.filters">
    <filter token="YEAR" value="${year}"/>
    <filter token="VERSION" value="${version}"/>
    <filter token="VERSION_NUMBER" value="${version.number}"/>
    <filter token="VERSION_MAJOR" value="${version.major}"/>
    <filter token="VERSION_MAJOR_MINOR" value="${version.major.minor}"/>
  </filterset>

  <!-- Files that need to have their line endings changed for src distros -->
  <patternset id="src.files" >
    <include name="**/INSTALLLICENSE"/>
    <include name="**/KEYS"/>
    <include name="**/LICENSE"/>
    <include name="**/NOTICE"/>
    <include name="**/RELEASE-NOTES"/>
    <include name="**/*.bat"/>
    <include name="**/*.classpath"/>
    <include name="**/*.dtd"/>
    <include name="**/*.htm"/>
    <include name="**/*.html"/>
    <include name="**/*.ini"/>
    <include name="**/*.java"/>
    <include name="**/*.jjt"/>
    <include name="**/*.jsp"/>
    <include name="**/*.jspf"/>
    <include name="**/*.jspx"/>
    <include name="**/*.license"/>
    <include name="**/*.manifest"/>
    <include name="**/*.mdl"/>
    <include name="**/*.notice"/>
    <include name="**/*.nsi"/>
    <include name="**/*.policy"/>
    <include name="**/*.pom"/>
    <include name="**/*.project"/>
    <include name="**/*.properties"/>
    <include name="**/*.properties.default"/>
    <include name="**/*.sh"/>
    <include name="**/*.svg"/>
    <include name="**/*.tag"/>
    <include name="**/*.tagx"/>
    <include name="**/*.tasks"/>
    <include name="**/*.tld"/>
    <include name="**/*.txt"/>
    <include name="**/*.xml"/>
    <include name="**/*.xsd"/>
    <include name="**/*.xsl"/>
  </patternset>

  <!-- ====================== COMBO: Clean All Directories ================ -->
  <target name="clean"
   description="Clean all components">

    <delete dir="${tomcat.deployer}"/>
    <delete dir="${tomcat.dist}" failonerror="false"/>
  </target>


  <!-- ====================== DIST: Create Directories ==================== -->
  <target name="dist-prepare">
    <mkdir dir="${tomcat.dist}"/>
    <mkdir dir="${tomcat.dist}/bin"/>
    <mkdir dir="${tomcat.dist}/conf"/>
    <mkdir dir="${tomcat.dist}/lib"/>
    <mkdir dir="${tomcat.dist}/logs"/>
    <mkdir dir="${tomcat.dist}/temp"/>
    <mkdir dir="${tomcat.dist}/webapps"/>
    <mkdir dir="${tomcat.dist}/work"/>
    <mkdir dir="${tomcat.release}/v${version}/bin" />
    <mkdir dir="${tomcat.release}/v${version}/src" />
  </target>


  <!-- ====================== DIST: Copy Static Files ===================== -->
  <target name="dist-static" depends="dist-prepare">

    <!-- Copy the top-level documentation files -->
    <copy todir="${tomcat.dist}" encoding="ISO-8859-1">
      <filterset refid="version.filters"/>
      <fileset dir=".">
        <include name="INSTALLING.txt"/>
        <include name="LICENSE"/>
        <include name="NOTICE"/>
        <include name="RELEASE-NOTES"/>
        <include name="RUNNING.txt"/>
      </fileset>
    </copy>

    <!-- Copy the contents of each "build" directory -->
    <copy todir="${tomcat.dist}/bin">
      <fileset dir="${tomcat.build}/bin">
      </fileset>
    </copy>
    <copy todir="${tomcat.dist}/lib">
      <fileset dir="${tomcat.build}/lib" />
    </copy>
    <copy todir="${tomcat.dist}/conf">
      <fileset dir="${tomcat.build}/conf">
      </fileset>
    </copy>

    <copy todir="${tomcat.dist}/webapps">
      <fileset dir="${tomcat.build}/webapps">
        <exclude name="**/ROOT/WEB-INF/classes/**" />
        <exclude name="**/WEB-INF/src/**" />
      </fileset>
    </copy>

    <touch file="${tomcat.dist}/temp/safeToDelete.tmp" />

    <!-- Windows binaries for each platform -->
    <!-- 32 bit -->
    <copy file="${commons-daemon.home}/windows/prunsrv.exe"
        tofile="${tomcat.dist}/bin/tomcat${version.major}.exe" />
    <copy file="${commons-daemon.home}/windows/prunmgr.exe"
        tofile="${tomcat.dist}/bin/tomcat${version.major}w.exe" />
    <!-- 64 bit amd -->
    <copy file="${commons-daemon.home}/windows/amd64/prunsrv.exe"
        tofile="${tomcat.dist}/bin/x64/tomcat${version.major}.exe" />
    <!-- 64 bit ia -->
    <copy file="${commons-daemon.home}/windows/ia64/prunsrv.exe"
        tofile="${tomcat.dist}/bin/i64/tomcat${version.major}.exe" />
    <!-- tc native -->
    <copy file="${tomcat-native.home}/tcnative-1.dll.x86"
        tofile="${tomcat.dist}/bin/tcnative-1.dll" />
    <!-- tc native 64 bit for amd/emt -->
    <copy file="${tomcat-native.home}/tcnative-1.dll.x64"
        tofile="${tomcat.dist}/bin/x64/tcnative-1.dll" />
    <!-- tc native 64 bit for ia -->
    <copy file="${tomcat-native.home}/tcnative-1.dll.i64"
        tofile="${tomcat.dist}/bin/i64/tcnative-1.dll" />

    <!-- Correct permissions and line endings on "bin" scripts -->
    <fixcrlf srcdir="${tomcat.dist}/bin" includes="*.sh"  eol="lf"   encoding="ISO-8859-1" fixlast="false" />
    <fixcrlf srcdir="${tomcat.dist}/bin" includes="*.bat" eol="crlf" encoding="ISO-8859-1" fixlast="false" />
    <chmod      dir="${tomcat.dist}/bin" includes="*.sh"  perm="+x"/>

  </target>

  <target name="dist-javadoc" depends="dist-source"
    description="Create the Tomcat javadoc" >
    <javadoc packagenames="org.apache.*"
      sourcepath="${tomcat.dist}/src/java"
      destdir="${tomcat.dist}/webapps/docs/api"
      author="true" version="true"
      windowtitle="Apache Tomcat ${version} API Documentation"
      doctitle="Apache Tomcat ${version} API"
      header="&lt;b&gt;Apache Tomcat ${version}&lt;/b&gt;"
      bottom="Copyright &amp;#169; 2000-${year} Apache Software Foundation. All Rights Reserved."
      additionalparam="-breakiterator"
      maxmemory="256m" >
    </javadoc>
  </target>

  <target name="dist-deployer" description="Create the Tomcat deployer binary" >

    <!-- Servlet and JSP -->
    <copy todir="${tomcat.deployer}/lib">
      <fileset dir="${tomcat.build}/lib">
        <include name="catalina-ant.jar"/>
        <include name="el-api.jar"/>
        <include name="jsp-api.jar"/>
        <include name="jasper.jar"/>
        <include name="jasper-el.jar"/>
        <include name="servlet-api.jar"/>
      </fileset>
      <fileset dir="${tomcat.build}/bin">
        <include name="tomcat-juli.jar"/>
      </fileset>
    </copy>

    <!-- Digester and dependencies -->
    <jar jarfile="${tomcat.deployer}/lib/catalina-deployer.jar">
       <fileset dir="${tomcat.classes}">
          <include name="org/apache/catalina/startup/DigesterFactory.class" />
          <include name="org/apache/catalina/util/SchemaResolver.class" />
          <include name="org/apache/catalina/util/StringManager.class" />
          <include name="org/apache/tomcat/util/*" />
          <include name="org/apache/tomcat/util/digester/*" />
          <exclude name="**/package.html" />
          <exclude name="**/LocalStrings_*" />
       </fileset>
    </jar>

    <!-- Main build script -->
    <copy todir="${tomcat.deployer}">
      <fileset dir="${basedir}/res/deployer" />
    </copy>

    <!-- Copy deployer documentation -->
    <copy todir="${tomcat.deployer}">
      <fileset dir="${tomcat.build}/webapps/docs">
        <include name="images/asf-logo.gif" />
        <include name="images/tomcat.gif" />
      </fileset>
    </copy>
    <copy tofile="${tomcat.deployer}/deployer-howto.html"
      file="${tomcat.build}/webapps/docs/deployer-howto.html"/>

  </target>

  <!-- ====================== DIST: Create Sources ======================== -->
  <target name="dist-source">

    <mkdir dir="${tomcat.dist}/src"/>

    <!-- Tomcat source -->
    <copy todir="${tomcat.dist}/src">
      <fileset dir="${basedir}">
        <exclude name=".*/**"/>
        <exclude name="output/**"/>
        <exclude name="build.properties"/>
      </fileset>
    </copy>

  </target>

  <!-- ================= DIST: Create Windows Installer =================== -->
  <target name="installer"
   description="Create Windows installer" unless="skip.installer">
    <echo message="Builds a Windows installer based on Nullsoft Installer"/>
    <copy todir="${tomcat.dist}">
      <fileset dir="res" />
    </copy>
    <copy file="${nsis.installoptions.dll}" todir="${tomcat.dist}" />
    <copy file="${nsis.nsexec.dll}" todir="${tomcat.dist}" />
    <copy file="${nsis.nsisdl.dll}" todir="${tomcat.dist}" />

    <fixcrlf srcdir="${tomcat.dist}" includes="*.txt,LICENSE,NOTICE" eol="crlf" encoding="ISO-8859-1" fixlast="false" />
    <fixcrlf srcdir="${tomcat.dist}/conf" eol="crlf" encoding="ISO-8859-1" fixlast="false" />
    <!-- Make sure the RELEASE-NOTES has Windows line endings as they may be
         displayed post-install -->
    <fixcrlf srcdir="${tomcat.dist}/webapps/ROOT"
        includes="RELEASE-NOTES.txt" eol="crlf" encoding="ISO-8859-1" fixlast="false" />
    <copy file="res/tomcat.nsi" tofile="${tomcat.dist}/tomcat.nsi" overwrite="true" encoding="ISO-8859-1">
      <filterset refid="version.filters"/>
    </copy>
    <exec dir="${tomcat.dist}" executable="${nsis.exe}" osfamily="windows">
      <arg value="/DNSISDIR=${nsis.home}" />
      <arg value="tomcat.nsi" />
    </exec>
    <exec dir="${tomcat.dist}" executable="wine" osfamily="unix">
      <arg value="${nsis.exe}" />
      <arg value="/DNSISDIR=${nsis.home}" />
      <arg value="tomcat.nsi" />
    </exec>

    <!-- Restore original line ending-->
    <fixcrlf srcdir="${tomcat.dist}/webapps/ROOT"
        includes="RELEASE-NOTES.txt" encoding="ISO-8859-1" fixlast="false" />

    <move file="${tomcat.dist}/tomcat-installer.exe" tofile="${tomcat.release}/v${version}/bin/${final.name}.exe" />

    <antcall target="md5sum">
      <param name="file" value="${tomcat.release}/v${version}/bin/${final.name}.exe" />
    </antcall>
  </target>


  <!-- ==================== RELEASE: Create Release ======================= -->
  <target name="release" depends="clean,dist-static,dist-deployer,installer,package-zip,package-winzip,package-tgz,package-deployer-zip,package-deployer-tgz,dist-source,dist-javadoc,package-docs-tgz,package-src-zip,package-src-tgz"
   description="Create a Tomcat 6 packaged distribution">

    <copy file="KEYS"
         todir="${tomcat.release}/v${version}"/>
    <copy file="RELEASE-NOTES"
         todir="${tomcat.release}/v${version}"
         encoding="ISO-8859-1">
      <filterset refid="version.filters"/>
    </copy>
    <copy file="res/welcome.main.html"
        tofile="${tomcat.release}/v${version}/README.html"
        encoding="ISO-8859-1">
      <filterset refid="version.filters"/>
    </copy>
    <copy file="res/welcome.bin.html"
        tofile="${tomcat.release}/v${version}/bin/README.html"
        encoding="ISO-8859-1">
      <filterset refid="version.filters"/>
    </copy>

    <mkdir dir="${tomcat.release}/v${version}/bin/extras" />
    <copy todir="${tomcat.release}/v${version}/bin/extras">
      <fileset dir="${tomcat.extras}">
        <include name="*.*"/>
      </fileset>
    </copy>

  </target>

  <!-- Packages the core zip distro -->
  <target name="package-zip">
    <fixcrlf srcdir="${tomcat.dist}" includes="*.txt,LICENSE,NOTICE" eol="crlf" encoding="ISO-8859-1" fixlast="false" />
    <fixcrlf srcdir="${tomcat.dist}/conf" eol="crlf" encoding="ISO-8859-1" fixlast="false" />
    <zip zipfile="${tomcat.release}/v${version}/bin/${final.name}.zip">
      <zipfileset dir="${tomcat.dist}" prefix="${final.name}">
        <include name="bin/**"/>
        <include name="conf/**"/>
        <include name="logs/**"/>
        <include name="lib/**"/>
        <include name="webapps/**"/>
        <include name="work/**"/>
        <include name="temp/**"/>
        <include name="LICENSE"/>
        <include name="NOTICE"/>
        <include name="README.txt"/>
        <include name="RELEASE-NOTES"/>
        <include name="RUNNING.txt"/>
        <include name="BENCHMARKS.txt"/>
        <exclude name="bin/service.bat"/>
        <exclude name="bin/x64/"/>
        <exclude name="bin/i64/"/>
        <exclude name="bin/*.exe"/>
        <exclude name="bin/*.dll"/>
      </zipfileset>
    </zip>

    <antcall target="md5sum">
      <param name="file" value="${tomcat.release}/v${version}/bin/${final.name}.zip" />
    </antcall>
  </target>

  <!-- Packages the core windows zip distros -->
  <target name="package-winzip">
    <fixcrlf srcdir="${tomcat.dist}" includes="*.txt,LICENSE,NOTICE" eol="crlf" encoding="ISO-8859-1" fixlast="false" />
    <fixcrlf srcdir="${tomcat.dist}/conf" eol="crlf" encoding="ISO-8859-1" fixlast="false" />

    <!-- Windows x86 package -->
    <zip zipfile="${tomcat.release}/v${version}/bin/${final.name}-windows-x86.zip">
      <zipfileset dir="${tomcat.dist}" prefix="${final.name}">
        <include name="bin/**"/>
        <include name="conf/**"/>
        <include name="logs/**"/>
        <include name="lib/**"/>
        <include name="webapps/**"/>
        <include name="work/**"/>
        <include name="temp/**"/>
        <include name="LICENSE"/>
        <include name="NOTICE"/>
        <include name="README.txt"/>
        <include name="RELEASE-NOTES"/>
        <include name="RUNNING.txt"/>
        <include name="BENCHMARKS.txt"/>
        <exclude name="bin/x64/"/>
        <exclude name="bin/i64/"/>
      </zipfileset>

    </zip>
    <antcall target="md5sum">
      <param name="file" value="${tomcat.release}/v${version}/bin/${final.name}-windows-x86.zip" />
    </antcall>

    <!-- Windows x64 package -->
    <zip zipfile="${tomcat.release}/v${version}/bin/${final.name}-windows-x64.zip">
      <zipfileset dir="${tomcat.dist}" prefix="${final.name}">
        <include name="bin/**"/>
        <include name="conf/**"/>
        <include name="logs/**"/>
        <include name="lib/**"/>
        <include name="webapps/**"/>
        <include name="work/**"/>
        <include name="temp/**"/>
        <include name="LICENSE"/>
        <include name="NOTICE"/>
        <include name="README.txt"/>
        <include name="RELEASE-NOTES"/>
        <include name="RUNNING.txt"/>
        <include name="BENCHMARKS.txt"/>
        <exclude name="bin/x64/"/>
        <exclude name="bin/i64/"/>
        <exclude name="bin/*.dll"/>
        <exclude name="bin/tomcat${version.major}.exe"/>
      </zipfileset>
      <zipfileset dir="${tomcat.dist}/bin/x64" prefix="${final.name}/bin">
        <include name="*.dll"/>
        <include name="*.exe"/>
      </zipfileset>
    </zip>
    <antcall target="md5sum">
      <param name="file" value="${tomcat.release}/v${version}/bin/${final.name}-windows-x64.zip" />
    </antcall>

    <!-- Windows i64 package -->
    <zip zipfile="${tomcat.release}/v${version}/bin/${final.name}-windows-i64.zip">
      <zipfileset dir="${tomcat.dist}" prefix="${final.name}">
        <include name="bin/**"/>
        <include name="conf/**"/>
        <include name="logs/**"/>
        <include name="lib/**"/>
        <include name="webapps/**"/>
        <include name="work/**"/>
        <include name="temp/**"/>
        <include name="LICENSE"/>
        <include name="NOTICE"/>
        <include name="README.txt"/>
        <include name="RELEASE-NOTES"/>
        <include name="RUNNING.txt"/>
        <include name="BENCHMARKS.txt"/>
        <exclude name="bin/x64/"/>
        <exclude name="bin/i64/"/>
        <exclude name="bin/*.dll"/>
        <exclude name="bin/tomcat${version.major}.exe"/>
      </zipfileset>
      <zipfileset dir="${tomcat.dist}/bin/i64" prefix="${final.name}/bin">
        <include name="*.dll"/>
        <include name="*.exe"/>
      </zipfileset>
    </zip>

    <antcall target="md5sum">
      <param name="file" value="${tomcat.release}/v${version}/bin/${final.name}-windows-i64.zip" />
    </antcall>

  </target>

  <!-- Packages the deployer distribution in zip format -->
  <target name="package-deployer-zip">
    <zip zipfile="${tomcat.release}/v${version}/bin/${final.name}-deployer.zip">
      <zipfileset dir="${tomcat.deployer}" prefix="${final.name}-deployer" includes="**" />
      <zipfileset dir="${tomcat.dist}" prefix="${final.name}-deployer" includes="LICENSE" />
      <zipfileset dir="${tomcat.dist}" prefix="${final.name}-deployer" includes="NOTICE" />
      <zipfileset dir="${tomcat.dist}" prefix="${final.name}-deployer" includes="README.txt" />
      <zipfileset dir="${tomcat.dist}" prefix="${final.name}-deployer" includes="RELEASE-NOTES" />
    </zip>

    <antcall target="md5sum">
      <param name="file" value="${tomcat.release}/v${version}/bin/${final.name}-deployer.zip" />
    </antcall>
  </target>

  <!-- Packages the core tar.gz distro -->
  <target name="package-tgz">
    <fixcrlf srcdir="${tomcat.dist}" includes="*.txt,LICENSE,NOTICE" eol="lf" encoding="ISO-8859-1" fixlast="false" />
    <fixcrlf srcdir="${tomcat.dist}/conf" eol="lf" encoding="ISO-8859-1" fixlast="false" />
    <tar longfile="gnu" compression="gzip"
         tarfile="${tomcat.release}/v${version}/bin/${final.name}.tar.gz">
      <tarfileset dir="${tomcat.dist}" mode="755" prefix="${final.name}">
        <include name="bin/catalina.sh" />
        <include name="bin/digest.sh" />
        <include name="bin/jasper.sh" />
        <include name="bin/jspc.sh" />
        <include name="bin/setclasspath.sh" />
        <include name="bin/startup.sh" />
        <include name="bin/shutdown.sh" />
        <include name="bin/tool-wrapper.sh" />
        <include name="bin/tool-wrapper-using-launcher.sh" />
        <include name="bin/shutdown-using-launcher.sh" />
        <include name="bin/startup-using-launcher.sh" />
        <include name="bin/version.sh" />
      </tarfileset>
      <tarfileset dir="${tomcat.dist}" mode="600" prefix="${final.name}">
        <include name="conf/**" />
      </tarfileset>
      <tarfileset dir="${tomcat.dist}" prefix="${final.name}">
        <include name="bin/**" />
        <include name="lib/**" />
        <include name="logs/**" />
        <include name="temp/**" />
        <include name="webapps/**" />
        <include name="work/**" />
        <include name="LICENSE" />
        <include name="NOTICE" />
        <include name="README.txt" />
        <include name="RELEASE-NOTES" />
        <include name="RUNNING.txt" />
        <include name="BENCHMARKS.txt" />
        <exclude name="bin/catalina.sh" />
        <exclude name="bin/digest.sh" />
        <exclude name="bin/jasper.sh" />
        <exclude name="bin/jspc.sh" />
        <exclude name="bin/service.bat"/>
        <exclude name="bin/setclasspath.sh" />
        <exclude name="bin/startup.sh" />
        <exclude name="bin/shutdown.sh" />
        <exclude name="bin/tool-wrapper.sh" />
        <exclude name="bin/tool-wrapper-using-launcher.sh" />
        <exclude name="bin/shutdown-using-launcher.sh" />
        <exclude name="bin/startup-using-launcher.sh" />
        <exclude name="bin/version.sh" />
        <exclude name="conf/**" />
        <exclude name="src/**" />
        <exclude name="bin/x64/"/>
        <exclude name="bin/i64/"/>
        <exclude name="bin/*.exe"/>
        <exclude name="bin/*.dll"/>
      </tarfileset>
    </tar>

    <antcall target="md5sum">
      <param name="file" value="${tomcat.release}/v${version}/bin/${final.name}.tar.gz" />
    </antcall>
  </target>

  <!-- Packages the deployer Tomcat distro in tar.gz format -->
  <target name="package-deployer-tgz">
    <fixcrlf srcdir="${tomcat.dist}"
     includes="*.txt,LICENSE,NOTICE" eol="lf" encoding="ISO-8859-1" fixlast="false" />
    <fixcrlf srcdir="${tomcat.deployer}" includes="*.xml" eol="lf" encoding="ISO-8859-1" fixlast="false" />

    <tar longfile="gnu" compression="gzip"
         tarfile="${tomcat.release}/v${version}/bin/${final.name}-deployer.tar.gz">
      <tarfileset dir="${tomcat.dist}" prefix="${final.name}-deployer">
        <include name="LICENSE" />
        <include name="NOTICE" />
        <include name="README.txt" />
        <include name="RELEASE-NOTES" />
      </tarfileset>
      <tarfileset dir="${tomcat.deployer}" prefix="${final.name}-deployer">
        <include name="**" />
      </tarfileset>
    </tar>

    <antcall target="md5sum">
      <param name="file" value="${tomcat.release}/v${version}/bin/${final.name}-deployer.tar.gz" />
    </antcall>
  </target>

  <!-- Packages the documentation distro in tar.gz format -->
  <target name="package-docs-tgz">

    <!-- Package gocs -->
    <fixcrlf srcdir="${tomcat.dist}" includes="*.txt,LICENSE,NOTICE" eol="lf" encoding="ISO-8859-1" fixlast="false" />

    <tar longfile="gnu" compression="gzip"
         tarfile="${tomcat.release}/v${version}/bin/${final.name}-fulldocs.tar.gz">
      <tarfileset dir="${tomcat.dist}" prefix="tomcat-${version.major.minor}-doc">
        <include name="LICENSE" />
        <include name="NOTICE" />
        <include name="README.txt" />
        <include name="RUNNING.txt" />
      </tarfileset>
      <tarfileset dir="${tomcat.dist}/webapps/docs" prefix="tomcat-${version.major.minor}-doc">
        <include name="**" />
      </tarfileset>
    </tar>

    <antcall target="md5sum">
      <param name="file" value="${tomcat.release}/v${version}/bin/${final.name}-fulldocs.tar.gz" />
    </antcall>
  </target>

  <!-- Packages the source code distribution in zip format -->
  <target name="package-src-zip">
    <fixcrlf srcdir="${tomcat.dist}/src" eol="crlf"
        encoding="ISO-8859-1" fixlast="false" >
      <patternset refid="src.files"/>
    </fixcrlf>
    <zip zipfile="${tomcat.release}/v${version}/src/${final-src.name}.zip">
      <zipfileset dir="${tomcat.dist}/src" prefix="${final-src.name}" />
    </zip>

    <antcall target="md5sum">
      <param name="file" value="${tomcat.release}/v${version}/src/${final-src.name}.zip" />
    </antcall>
  </target>

  <!-- Packages the source code distribution in tar.gz format -->
  <target name="package-src-tgz">
    <fixcrlf srcdir="${tomcat.dist}/src" eol="lf"
        encoding="ISO-8859-1" fixlast="false" >
      <patternset refid="src.files"/>
    </fixcrlf>
    <tar longfile="gnu" compression="gzip"
         tarfile="${tomcat.release}/v${version}/src/${final-src.name}.tar.gz">
      <tarfileset dir="${tomcat.dist}/src" prefix="${final-src.name}" />
    </tar>
    <antcall target="md5sum">
      <param name="file" value="${tomcat.release}/v${version}/src/${final-src.name}.tar.gz" />
    </antcall>
  </target>

  <!-- Helper target, used to create a md5 checksum file  -->
  <!-- Requires 'file' as a parameter. -->
  <target name="md5sum">
    <fail unless="file" />
    <fail if="filename" />
    <fail if="value" />
    <basename file="${file}" property="filename" />
    <checksum file="${file}" property="value" />
    <echo file="${file}.md5" message="${value}${md5sum.binary-prefix}${filename}" />
  </target>
</project>
