<project name="Tomcat 4.0" default="deploy" basedir=".">


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

  <!-- See "build.properties.sample" in the top level directory for all     -->
  <!-- property values you must customize for successful building!!!        -->
  <property file="${user.home}/build.properties"/>
  <property file="build.properties"/>
  <property file="build.properties.default"/>

  <!-- Project Properties -->
  <property name="name"                  value="Apache Tomcat" />
  <property name="year"                  value="2001" />
  <property name="version"               value="4.1" />
  <property name="project"               value="jakarta-tomcat" />
  <property name="final.name"            value="${project}-${version}" />
  <property name="final-src.name"        value="${project}-${version}-src" />
  <property name="jtc.project"           value="jakarta-tomcat-connectors" />
  <property name="jtc.final.name"        value="${jtc.project}-${version}" />
  <property name="jtc.final-src.name"    value="${jtc.project}-${version}-src" />
  <property name="servlet.doc"           value="${servlet.home}/docs/api" />

  <!-- Build Defaults -->
  <property name="catalina.build"   value="${basedir}/catalina/build"/>
  <property name="jasper.build"     value="${basedir}/jasper/build"/>
  <property name="javaservice.home" value="../javaservice"/>
  <property name="nsis.home"        value="c:\program files\nsis"/>
  <property name="servlet.home"     value="../jakarta-servletapi-4/dist"/>
  <property name="tomcat.build"     value="${basedir}/build"/>
  <property name="tomcat.dist"      value="${basedir}/dist"/>
  <property name="webapps.build"    value="${basedir}/webapps/build"/>
  <property name="webapps.dist"     value="${basedir}/webapps/dist"/>


  <!-- Source dependencies -->
  <property name="jasper.home"
           value="${basedir}/../jakarta-tomcat-jasper/jasper2"/>
  <property name="jtc.home"
           value="${basedir}/../jakarta-tomcat-connectors"/>


  <!-- =================== DETECT: Display configuration ================== -->
  <target name="detect"
   description="Display configuration and conditional compilation flags">

    <ant dir="${basedir}/catalina" target="flags.display"/>
    <ant dir="${basedir}/webapps/admin" target="flags.display"/>

  </target>


  <!-- ===================== DEPLOY: Create Directories =================== -->
  <target name="deploy-prepare">
    <mkdir dir="${tomcat.build}"/>
  </target>


  <!-- ====================== DEPLOY: Copy Static Files =================== -->
  <target name="deploy-static" depends="deploy-prepare"/>


  <!-- ====================== DEPLOY: Deploy Components =================== -->
  <target name="deploy" depends="deploy-static"
   description="Build and deploy all components">
    <echo>Target: Catalina - Deploy ...</echo>
    <ant dir="./catalina" target="deploy"/>
    <echo>Target: Jasper - Deploy ...</echo>
    <ant dir="${jasper.home}"   target="deploy">
      <property name="catalina.home" value="${tomcat.build}"/>
    </ant>
    <echo>Target: Webapps - Deploy ...</echo>
    <ant dir="./webapps"  target="deploy"/>
  </target>


  <!-- ====================== COMBO: Clean All Directories ================ -->
  <target name="clean"
   description="Clean all components">
    <delete dir="${tomcat.build}"/>
    <echo>Target: Catalina - Clean ...</echo>
    <ant dir="./catalina" target="clean"/>
    <echo>Target: Jasper - Clean ...</echo>
    <ant dir="${jasper.home}"   target="clean">
      <property name="catalina.home" value="${tomcat.build}"/>
    </ant>
    <echo>Target: Webapps - Clean ...</echo>
    <ant dir="./webapps"  target="clean"/>
    <delete dir="${tomcat.dist}"/>
  </target>


  <!-- ======================= COMBO: Build All Components ================ -->
  <target name="all"
   description="Clean, build, and deploy all components">
    <echo>Target: Catalina - All ...</echo>
    <ant dir="./catalina" target="all"/>
    <echo>Target: Jasper - All ...</echo>
    <ant dir="${jasper.home}"   target="all">
      <property name="catalina.home" value="${tomcat.build}"/>
    </ant>
    <echo>Target: Webapps - All ...</echo>
    <ant dir="./webapps"  target="all"/>
  </target>


  <!-- ======================= COMBO: Test All Components ================= -->
  <target name="test"
   description="Unit tests on all components">
    <echo>Target: Catalina - Test ...</echo>
    <ant dir="./catalina" target="test"/>
    <echo>Target: Jasper - Test ...</echo>
    <ant dir="${jasper.home}"   target="test">
      <property name="catalina.home" value="${tomcat.build}"/>
    </ant>
    <echo>Target: Webapps - Test ...</echo>
    <ant dir="./webapps"  target="test"/>
  </target>


  <!-- ====================== DIST: Create Directories ==================== -->
  <target name="dist-prepare">
    <mkdir dir="${tomcat.dist}"/>
    <mkdir dir="${tomcat.dist}/bin"/>
    <mkdir dir="${tomcat.dist}/common"/>
    <mkdir dir="${tomcat.dist}/common/classes"/>
    <mkdir dir="${tomcat.dist}/common/endorsed"/>
    <mkdir dir="${tomcat.dist}/common/lib"/>
    <mkdir dir="${tomcat.dist}/conf"/>
    <mkdir dir="${tomcat.dist}/logs"/>
    <mkdir dir="${tomcat.dist}/server"/>
    <mkdir dir="${tomcat.dist}/server/classes"/>
    <mkdir dir="${tomcat.dist}/server/lib"/>
    <mkdir dir="${tomcat.dist}/shared/classes"/>
    <mkdir dir="${tomcat.dist}/shared/lib"/>
    <mkdir dir="${tomcat.dist}/webapps"/>
    <mkdir dir="${tomcat.dist}/work"/>
    <mkdir dir="${tomcat.dist}/temp"/>
  </target>


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

    <!-- Copy the top-level documentation files -->
    <copy todir="${tomcat.dist}">
      <fileset dir=".">
        <include name="LICENSE"/>
        <include name="INSTALLING.txt"/>
        <include name="BUILDING.txt"/>
        <include name="README.txt"/>
        <include name="RELEASE*"/>
        <include name="RUNNING.txt"/>
      </fileset>
    </copy>

    <!-- Copy the contents of each "build" directory -->
    <copy todir="${tomcat.dist}/bin">
      <fileset dir="${tomcat.build}/bin" />
    </copy>
    <copy todir="${tomcat.dist}/common/classes">
      <fileset dir="${tomcat.build}/common/classes" />
    </copy>
    <copy todir="${tomcat.dist}/common/endorsed">
      <fileset dir="${tomcat.build}/common/endorsed" />
    </copy>
    <copy todir="${tomcat.dist}/common/lib">
      <fileset dir="${tomcat.build}/common/lib" />
    </copy>
    <copy todir="${tomcat.dist}/conf">
      <fileset dir="${tomcat.build}/conf" />
    </copy>
    <copy todir="${tomcat.dist}/server/classes">
      <fileset dir="${tomcat.build}/server/classes" />
    </copy>
    <copy todir="${tomcat.dist}/server/lib">
      <fileset dir="${tomcat.build}/server/lib" />
    </copy>
    <copy todir="${tomcat.dist}/server/webapps">
      <fileset dir="${tomcat.build}/server/webapps" />
    </copy>
    <copy todir="${tomcat.dist}/shared/classes">
      <fileset dir="${tomcat.build}/shared/classes" />
    </copy>
    <copy todir="${tomcat.dist}/shared/lib">
      <fileset dir="${tomcat.build}/shared/lib" />
    </copy>
    <copy todir="${tomcat.dist}/temp">
      <fileset dir="${tomcat.build}/temp" />
    </copy>
    <copy todir="${tomcat.dist}/webapps">
      <fileset dir="${tomcat.build}/webapps" />
    </copy>

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

  </target>


  <!-- ====================== DIST: Create Javadoc ======================== -->
  <target name="dist-javadoc">
    <ant dir="./catalina" target="javadoc"/>
    <mkdir  dir="${tomcat.dist}/webapps/tomcat-docs/catalina/docs/api"/>
    <copy todir="${tomcat.dist}/webapps/tomcat-docs/catalina/docs/api">
      <fileset dir="${catalina.build}/javadoc" />
    </copy>
    <ant dir="${jasper.home}" target="javadoc"/>
    <mkdir  dir="${tomcat.dist}/webapps/tomcat-docs/jasper/docs/api"/>
    <copy todir="${tomcat.dist}/webapps/tomcat-docs/jasper/docs/api">
      <fileset dir="${jasper.build}/javadoc" />
    </copy>
    <mkdir  dir="${tomcat.dist}/webapps/tomcat-docs/servletapi"/>
    <copy todir="${tomcat.dist}/webapps/tomcat-docs/servletapi">
      <fileset dir="${servlet.doc}" />
    </copy>
  </target>


  <!-- ====================== DIST: Create Sources ======================== -->
  <target name="dist-source">
    <mkdir  dir="${tomcat.dist}/src"/>
    <copy todir="${tomcat.dist}/src">
      <fileset dir="${basedir}">
        <exclude name="**/build/**"/>
        <exclude name="**/dist/**"/>
        <exclude name="jasper/**"/>
        <exclude name="build.properties"/>
      </fileset>
    </copy>
    <mkdir  dir="${tomcat.dist}/src/jasper"/>
    <copy todir="${tomcat.dist}/src/jasper">
      <fileset dir="${jasper.home}"/>
    </copy>
    <mkdir  dir="${tomcat.dist}/jtc-src"/>
    <copy todir="${tomcat.dist}/jtc-src">
      <fileset dir="${jtc.home}">
        <exclude name="coyote/build/**"/>
        <exclude name="http11/build/**"/>
        <exclude name="jk/build/**"/>
        <exclude name="util/build/**"/>
        <exclude name="webapp/build/**"/>
        <exclude name="build.properties"/>
      </fileset>
    </copy>
  </target>


  <!-- ====================== DIST: Create Archives ======================= -->
  <target name="dist" depends="deploy,dist-static,dist-javadoc"
   description="Create binary distribution">
  </target>


  <!-- ================= DIST: Create Windows Installer =================== -->
  <target name="installer"
   description="Create Windows installer" if="execute.installer">
    <echo message="Builds a Windows installer based on Nullsoft Installer"/>
    <echo message="NSIS must be installed in the default directory"/>
    <copy todir="${tomcat.dist}">
      <fileset dir="resources" />
    </copy>
    <copy file="${nsis.home}/Plugins/InstallOptions.dll" 
     todir="${tomcat.dist}" />
    <copy file="${javaservice.home}/bin/JavaService.exe" 
     tofile="${tomcat.dist}/bin/tomcat.exe" />
    <filter token="VERSION" value="${version}"/>
    <copy file="tomcat.nsi" tofile="${tomcat.dist}/tomcat.nsi" 
     filtering="true"/>
    <exec dir="${tomcat.dist}" executable="${nsis.home}\makensis.exe">
      <arg value="tomcat.nsi" />
    </exec>
    <move file="${tomcat.dist}/tomcat4.exe" 
     tofile="${tomcat.dist}/${final.name}.exe" />
  </target>


  <!-- ==================== RELEASE: Create Release ======================= -->
  <target name="release" depends="prepare-release,clean,dist,dist-source,installer,package-zip,package-tgz,package-src-zip,package-src-tgz"
   description="Create a Tomcat 4 packaged distribution" />

  <target name="package-zip">
    <zip zipfile="${tomcat.dist}/${final.name}.zip">
      <zipfileset dir="${tomcat.dist}" prefix="${final.name}" 
       includes="bin/**" />
      <zipfileset dir="${tomcat.dist}" prefix="${final.name}" 
       includes="common/**" />
      <zipfileset dir="${tomcat.dist}" prefix="${final.name}" 
       includes="conf/**" />
      <zipfileset dir="${tomcat.dist}" prefix="${final.name}" 
       includes="logs/**" />
      <zipfileset dir="${tomcat.dist}" prefix="${final.name}" 
       includes="server/**" />
      <zipfileset dir="${tomcat.dist}" prefix="${final.name}" 
       includes="shared/**" />
      <zipfileset dir="${tomcat.dist}" prefix="${final.name}" 
       includes="webapps/**" />
      <zipfileset dir="${tomcat.dist}" prefix="${final.name}" 
       includes="work/**" />
      <zipfileset dir="${tomcat.dist}" prefix="${final.name}"
       includes="temp/**" />
      <zipfileset dir="${tomcat.dist}" prefix="${final.name}" 
       includes="LICENSE" />
      <zipfileset dir="${tomcat.dist}" prefix="${final.name}" 
       includes="README.txt" />
      <zipfileset dir="${tomcat.dist}" prefix="${final.name}" 
       includes="RELEASE-NOTES-*" />
      <zipfileset dir="${tomcat.dist}" prefix="${final.name}" 
       includes="RELEASE-PLAN-*" />
      <zipfileset dir="${tomcat.dist}" prefix="${final.name}" 
       includes="RUNNING.txt" />
    </zip>
  </target>

  <target name="prepare-release">
    <condition property="execute.installer">
      <and>
        <os family="windows" />
        <available file="${javaservice.home}/bin/JavaService.exe" />
        <available file="${nsis.home}/makensis.exe" />
      </and>
    </condition>
  </target>

  <target name="package-tgz">
    <mkdir dir="${tomcat.dist}/${final.name}" />
    <copy todir="${tomcat.dist}/${final.name}">
      <fileset dir="${tomcat.dist}">
        <include name="bin/**" />
        <include name="common/**" />
        <include name="conf/**" />
        <include name="logs/**" />
        <include name="server/**" />
        <include name="shared/**" />
        <include name="webapps/**" />
        <include name="work/**" />
        <include name="temp/**" />
        <include name="LICENSE" />
        <include name="README.txt" />
        <include name="RELEASE-NOTES-*" />
        <include name="RELEASE-PLAN-*" />
        <include name="RUNNING.txt" />
      </fileset>
    </copy>
    <fixcrlf srcdir="${tomcat.dist}/${final.name}" 
     includes="*.txt,LICENSE" eol="lf"/>
    <fixcrlf srcdir="${tomcat.dist}/${final.name}/conf" eol="lf"/>
    <tar longfile="gnu" tarfile="${tomcat.dist}/${final.name}.tar">
      <tarfileset dir="${tomcat.dist}" mode="755">
        <include name="${final.name}/bin/catalina.sh" />
        <include name="${final.name}/bin/digest.sh" />
        <include name="${final.name}/bin/jasper.sh" />
        <include name="${final.name}/bin/jspc.sh" />
        <include name="${final.name}/bin/setclasspath.sh" />
        <include name="${final.name}/bin/startup.sh" />
        <include name="${final.name}/bin/shutdown.sh" />
        <include name="${final.name}/bin/tool-wrapper.sh" />
      </tarfileset>
      <tarfileset dir="${tomcat.dist}">
        <include name="${final.name}/**" />
        <exclude name="${final.name}/bin/catalina.sh" />
        <exclude name="${final.name}/bin/digest.sh" />
        <exclude name="${final.name}/bin/jasper.sh" />
        <exclude name="${final.name}/bin/jspc.sh" />
        <exclude name="${final.name}/bin/setclasspath.sh" />
        <exclude name="${final.name}/bin/startup.sh" />
        <exclude name="${final.name}/bin/shutdown.sh" />
        <exclude name="${final.name}/bin/tool-wrapper.sh" />
      </tarfileset>
    </tar>
    <delete dir="${tomcat.dist}/${final.name}" />
    <gzip zipfile="${tomcat.dist}/${final.name}.tar.gz"
     src="${tomcat.dist}/${final.name}.tar"/>
    <delete file="${tomcat.dist}/${final.name}.tar" />
  </target>

  <target name="package-src-zip">
    <!-- Package Tomcat Source -->
    <zip zipfile="${tomcat.dist}/${final-src.name}.zip">
      <zipfileset dir="${tomcat.dist}/src" prefix="${final-src.name}" />
    </zip>
    <!-- Package JTC Source -->
    <zip zipfile="${tomcat.dist}/${jtc.final-src.name}.zip">
      <zipfileset dir="${tomcat.dist}/jtc-src" 
               prefix="${jtc.final-src.name}" />
    </zip>
  </target>

  <target name="package-src-tgz">
    <!-- Package Tomcat Source -->
    <mkdir dir="${tomcat.dist}/${final-src.name}" />
    <copy todir="${tomcat.dist}/${final-src.name}">
      <fileset dir="${tomcat.dist}/src">
        <include name="**" />
      </fileset>
    </copy>
    <fixcrlf srcdir="${tomcat.dist}/${final-src.name}" 
     excludes="**/*.jar,**/*.gif,**/*.bmp,**/*.jpg,**/*.ico" eol="lf"/>
    <tar longfile="gnu" tarfile="${tomcat.dist}/${final-src.name}.tar">
      <tarfileset dir="${tomcat.dist}">
        <include name="${final-src.name}/**" />
      </tarfileset>
    </tar>
    <delete dir="${tomcat.dist}/${final-src.name}" />
    <gzip zipfile="${tomcat.dist}/${final-src.name}.tar.gz"
     src="${tomcat.dist}/${final-src.name}.tar"/>
    <delete file="${tomcat.dist}/${final-src.name}.tar" />
    <!-- Package JTC Source -->
    <mkdir dir="${tomcat.dist}/${jtc.final-src.name}" />
    <copy todir="${tomcat.dist}/${jtc.final-src.name}">
      <fileset dir="${tomcat.dist}/jtc-src">
        <include name="**" />
      </fileset>
    </copy>
    <!-- Note: Will break with Ant 1.4.1; Works with 1.5 Alpha -->
    <fixcrlf srcdir="${tomcat.dist}/${jtc.final-src.name}" 
     excludes="**/*.jar,**/*.gif,**/*.bmp,**/*.jpg,**/*.ico" eol="lf"/>
    <tar longfile="gnu" tarfile="${tomcat.dist}/${jtc.final-src.name}.tar">
      <tarfileset dir="${tomcat.dist}" mode="755">
        <include name="${jtc.final-src.name}/jk/native/buildconf.sh" />
        <include name="${jtc.final-src.name}/jk/native/apache-1.3/build-hpux-cc.sh" />
        <include name="${jtc.final-src.name}/jk/native/apache-1.3/build-solaris.sh" />
        <include name="${jtc.final-src.name}/jk/native/apache-1.3/build-unix.sh" />
        <include name="${jtc.final-src.name}/jk/native/apache-2.0/build-unix.sh" />
        <include name="${jtc.final-src.name}/jk/native/apache-2.0/install-unix.sh" />
        <include name="${jtc.final-src.name}/jk/native/domino/mkini.sh" />
        <include name="${jtc.final-src.name}/webapp/support/buildconf.sh" />
        <include name="${jtc.final-src.name}/webapp/support/install.sh" />
        <include name="${jtc.final-src.name}/webapp/support/mkinstalldirs.sh" />
      </tarfileset>
      <tarfileset dir="${tomcat.dist}">
        <include name="${jtc.final-src.name}/**" />
        <exclude name="${jtc.final-src.name}/jk/native/buildconf.sh" />
        <exclude name="${jtc.final-src.name}/jk/native/apache-1.3/build-hpux-cc.sh" />
        <exclude name="${jtc.final-src.name}/jk/native/apache-1.3/build-solaris.sh" />
        <exclude name="${jtc.final-src.name}/jk/native/apache-1.3/build-unix.sh" />
        <exclude name="${jtc.final-src.name}/jk/native/apache-2.0/build-unix.sh" />
        <exclude name="${jtc.final-src.name}/jk/native/apache-2.0/install-unix.sh" />
        <exclude name="${jtc.final-src.name}/jk/native/domino/mkini.sh" />
        <exclude name="${jtc.final-src.name}/webapp/support/buildconf.sh" />
        <exclude name="${jtc.final-src.name}/webapp/support/install.sh" />
        <exclude name="${jtc.final-src.name}/webapp/support/mkinstalldirs.sh" />
      </tarfileset>
    </tar>
    <delete dir="${tomcat.dist}/${jtc.final-src.name}" />
    <gzip zipfile="${tomcat.dist}/${jtc.final-src.name}.tar.gz"
     src="${tomcat.dist}/${jtc.final-src.name}.tar"/>
    <delete file="${tomcat.dist}/${jtc.final-src.name}.tar" />
  </target>

  <target name="download" depends="proxyflags">
    <!-- Downdown any sub package or tools needed. -->
    <antcall target="downloadgz">
      <param name="sourcefile" value="${commons-beanutils.loc}"/>
      <param name="destfile" value="${commons-beanutils.jar}"/>
    </antcall>
    <antcall target="downloadgz">
      <param name="sourcefile" value="${commons-fileupload.loc}"/>
      <param name="destfile" value="${commons-fileupload.jar}"/>
    </antcall>
    <antcall target="downloadgz">
      <param name="sourcefile" value="${commons-collections.loc}"/>
      <param name="destfile" value="${commons-collections.jar}"/>
    </antcall>
    <antcall target="downloadgz">
      <param name="sourcefile" value="${tyrex.loc}"/>
      <param name="destfile" value="${tyrex.jar}"/>
    </antcall>
    <antcall target="downloadgz">
      <param name="sourcefile" value="${commons-digester.loc}"/>
      <param name="destfile" value="${commons-digester.jar}"/>
    </antcall>

    <!-- Commons Logging    -->
    <antcall target="downloadgz">
      <param name="sourcefile" value="${commons-logging.loc}"/>
      <param name="destfile" value="${commons-logging.jar}"/>
    </antcall>

    <antcall target="downloadgz">
      <param name="sourcefile" value="${regexp.loc}"/>
      <param name="destfile" value="${regexp.jar}"/>
    </antcall>
    <!-- Servlet api needs something different. -->

    <antcall target="cvsbuild">
      <param name="location" value="${servlet.loc}"/>
      <param name="subdir" value="${servlet.home}"/>
      <param name="destfile" value="${servlet.jar}"/>
    </antcall>

    <antcall target="downloadgz">
      <!-- xerces2 brings 2 files, test for one of them -->
      <param name="sourcefile" value="${xerces.loc}"/>
      <param name="destfile" value="${xmlParserAPIs.jar}"/>
    </antcall>
    <!-- commons- daemons/dbcp/pool need something different. -->
    <antcall target="downloadgz">
      <param name="sourcefile" value="${commons-daemon.loc}"/>
      <param name="destfile" value="${commons-daemon.jar}"/>
    </antcall>
    <!-- Pool 1.0 -->
    <antcall target="downloadgz">
      <param name="sourcefile" value="${commons-pool.loc}"/>
      <param name="destfile" value="${commons-pool.jar}"/>
    </antcall>

    <antcall target="downloadgz">
      <param name="sourcefile" value="${commons-dbcp.loc}" />
      <param name="destfile" value="${commons-dbcp.jar}" />
    </antcall>
    <antcall target="downloadgz">
      <param name="sourcefile" value="${commons-modeler.loc}"/>
      <param name="destfile" value="${commons-modeler.jar}"/>
    </antcall>
    <antcall target="downloadzip">
      <param name="sourcefile" value="${javaservice.loc}"/>
      <param name="destfile" value="${javaservice.home}/bin/JavaService.exe"/>
      <param name="destdir" value="${javaservice.home}"/>
    </antcall>
    <antcall target="downloadgz">
      <param name="sourcefile" value="${jmx.loc}"/>
      <param name="destfile" value="${jmx.jar}"/>
    </antcall>
    <antcall target="downloadzip">
      <param name="sourcefile" value="${junit.loc}"/>
      <param name="destfile" value="${junit.jar}"/>
      <param name="destdir" value="${base.path}"/>
    </antcall>
    <antcall target="downloadfile">
      <param name="sourcefile" value="${nsis.loc}"/>
      <param name="destfile" value="${nsis.home}/nsis198.exe"/>
      <param name="destdir" value="${nsis.home}"/>
    </antcall>
    <antcall target="downloadgz">
      <param name="sourcefile" value="${struts.loc}"/>
      <param name="destfile" value="${struts.jar}"/>
    </antcall>
<!--
    <antcall target="downloadfile">
      <param name="sourcefile" value="${tyrex.loc}"/>
      <param name="destfile" value="${tyrex.jar}"/>
      <param name="destdir" value="${tyrex.home}"/>
    </antcall>
-->
  </target>

  <target name="proxyflags">
    <!-- check proxy parameters. -->
    <condition property="useproxy">
      <equals arg1="${proxy.use}" arg2="on" />
    </condition>
  </target>

  <target name="setproxy"  if="useproxy">
    <taskdef name="setproxy"
      classname="org.apache.tools.ant.taskdefs.optional.net.SetProxy" />
    <setproxy proxyhost="${proxy.host}" proxyport="${proxy.port}"/> 
    <echo message="Using ${proxy.host}:${proxy.port} to download ${sourcefile}"/>
  </target>

  <target name="testexist">
    <echo message="Testing  for ${destfile}"/>
    <available file="${destfile}" property="exist"/>
  </target>

  <target name="downloadgz" unless="exist" depends="setproxy,testexist">
    <!-- Download and extract the package -->
    <get src="${sourcefile}" dest="${base.path}/file.tar.gz" />
    <gunzip src="${base.path}/file.tar.gz" dest="${base.path}/file.tar"/>
    <untar src="${base.path}/file.tar" dest="${base.path}"/>
    <delete file="${base.path}/file.tar"/>
    <delete file="${base.path}/file.tar.gz"/>
  </target>

  <target name="downloadzip" unless="exist" depends="setproxy,testexist">
    <!-- Download and extract the package -->
    <get src="${sourcefile}" dest="${base.path}/file.zip" />
    <mkdir dir="${destdir}" />
    <unzip src="${base.path}/file.zip" dest="${destdir}"/>
    <delete file="${base.path}/file.zip"/>
  </target>

  <target name="downloadfile" unless="exist" depends="setproxy,testexist">
    <!-- Download extract the file -->
    <mkdir dir="${destdir}" />
    <get src="${sourcefile}" dest="${destfile}" />
  </target>

  <target name="cvsbuild" unless="exist" depends="testexist">
    <!-- cvs checkout and ant dist + copy of jar file -->
    <echo message="cvs co ${location} and ant dist in ${subdir}"/>
    <mkdir dir="${base.path}/tmp"/>
    <cvs cvsRoot="${cvsroot}"
      package="${location}"
      dest="${base.path}/tmp"
    />
    <!-- the software is checked out in ${{base.path}/tmp/${location} -->
    <move todir="${subdir}">
      <fileset dir="${base.path}/tmp/${location}/"/>
    </move>
    <!-- now build the distribution -->
    <ant dir="${subdir}" target="dist"/>
  </target>

  <target name="jfc">
    <antcall target="cvsbuild">
      <param name="location" value="${commons-daemon.loc}"/>
      <param name="subdir" value="${commons-daemon.home}"/>
      <param name="destfile" value="${commons-daemon.jar}"/>
    </antcall>
  </target>

</project>
