<?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="apache-ant" default="main" basedir=".">

  <!-- Give user a chance to override without editing this file
       (and without typing -D on each invocation) -->
  <property file=".ant.properties"/>
  <property file="${user.home}/.ant.properties"/>
  <property environment="env"/>


  <!--
       ===================================================================
         Set the properties that control names and versions
       ===================================================================
  -->
  <property name="Name" value="Apache Ant"/>
  <property name="name" value="ant"/>
  <!-- this is the groupId of ant in the Maven repository -->
  <property name="groupid" value="org/apache/ant"/>
  <property name="project.version" value="1.10.2alpha"/>
  <!-- pom.version is used when doing a distribution and must match with what is checked in under src/etc/poms -->
  <property name="pom.version" value="1.10.2-SNAPSHOT"/>
  <property name="manifest-version" value="1.10.2"/>
  <property name="bootstrap.jar" value="ant-bootstrap.jar"/>

  <property name="ant.package" value="org/apache/tools/ant"/>
  <property name="taskdefs.package" value="${ant.package}/taskdefs"/>
  <property name="condition.package" value="${taskdefs.package}/condition"/>
  <property name="optional.package" value="${taskdefs.package}/optional"/>
  <property name="type.package" value="${ant.package}/types"/>
  <property name="optional.type.package" value="${type.package}/optional"/>
  <property name="apache.resolver.type.package" value="${ant.package}/types/resolver"/>
  <property name="util.package" value="${ant.package}/util"/>
  <property name="regexp.package" value="${util.package}/regexp"/>

  <property name="optional.jars.prefix" value="ant"/>
  <property name="optional.jars.whenmanifestonly" value="skip"/>

  <!--
       ===================================================================
         Set the properties related to the source tree
       ===================================================================
  -->
  <property name="src.dir" value="src"/>
  <property name="java.dir" value="${src.dir}/main"/>
  <property name="script.dir" value="${src.dir}/script"/>
  <property name="lib.dir" value="lib"/>
  <property name="manual.dir" value="manual"/>
  <property name="etc.dir" value="${src.dir}/etc"/>
  <property name="src.junit" value="${src.dir}/tests/junit"/>
  <property name="src.antunit" value="${src.dir}/tests/antunit"/>
  <property name="tests.etc.dir" value="${src.dir}/etc/testcases"/>
  <property name="manifest" value="${src.dir}/etc/manifest"/>
  <property name="resource.dir" value="${src.dir}/resources"/>

  <!--
       ===================================================================
         Set the properties for the build area
       ===================================================================
  -->
  <property name="build.dir" value="build"/>
  <property name="bootstrap.dir" location="bootstrap"/>
  <property name="build.classes" value="${build.dir}/classes"/>
  <property name="build.lib" value="${build.dir}/lib"/>
  <property name="build.lib-src" value="${build.dir}/lib-src"/>
  <property name="build.javadocs" value="${build.dir}/javadocs"/>
  <property name="build.tests" value="${build.dir}/testcases"/>
  <property name="build.tests.javadocs" value="${build.dir}/javadocs.test/"/>
  <property name="build.junit.xml" location="${build.tests}/xml"/>
  <property name="build.junit.tmpdir" location="${build.tests}/tmp"/>
  <property name="antunit.xml" location="${build.dir}/antunit/xml"/>
  <property name="antunit.tmpdir" location="${build.dir}/antunit/tmp"/>
  <property name="antunit.reports" location="${build.dir}/antunit/reports"/>
  <property name="antunit.loglevel" value="none"/>
  <property name="build.junit.reports" location="${build.tests}/reports"/>
  <property name="manifest.tmp" value="${build.dir}/optional.manifest"/>
  <!-- the absolute path -->
  <property name="build.tests.value" location="${build.tests}"/>

  <!--
       ===================================================================
         Set the properties that control various build options
       ===================================================================
  -->
  <property name="debug" value="true"/>
  <property name="setpermissions.fail" value="true"/>
  <property name="setpermissions.nonposixmode" value="tryDosOrPass"/>
  <property name="deprecation" value="false"/>
  <property name="optimize" value="true"/>
  <property name="javac.target" value="1.8"/>
  <property name="javac.source" value="1.8"/>
  <property name="junit.filtertrace" value="off"/>
  <property name="junit.summary" value="no"/>
  <property name="test.haltonfailure" value="false"/>
  <property name="junit.fork" value="true"/>
  <property name="junit.forkmode" value="once"/>
  <condition property="junit.threads" value="2" else="0">
    <and>
      <equals arg1="${junit.fork}" arg2="true"/>
      <equals arg1="${junit.forkmode}" arg2="perTest"/>
    </and>
  </condition>
  <property name="expandproperty.files"
            value="**/version.txt,**/defaultManifest.mf"/>
  <property name="junit.collector.dir" value="${build.dir}/failingTests"/>
  <property name="junit.collector.class" value="FailedTests"/>

  <!--
       ===================================================================
         Set the paths used in the build
       ===================================================================
  -->
  <path id="classpath">
    <fileset dir="lib/optional" includes="*.jar"/>
  </path>

  <path id="tests-classpath">
    <pathelement location="${build.classes}"/>
    <path refid="classpath"/>
  </path>
  <path id="tests-runtime-classpath">
    <path refid="tests-classpath"/>
    <pathelement location="${build.tests}"/>
    <!--
        include the test source and test data dirs
        so that we can pick resources via getResource(AsStream)
     -->
    <pathelement location="${src.junit}"/>
    <pathelement location="${tests.etc.dir}"/>
    <!-- Otherwise many tests fail with "com.sun.tools.javac.Main is not on the classpath.": -->
    <pathelement location="${java.home}/../lib/tools.jar"/>
  </path>

  <!--
        ===================================================================
          Set up properties for the distribution area
        ===================================================================
   -->
  <property name="dist.name" value="apache-${name}-${project.version}"/>
  <property name="dist.base" value="distribution"/>
  <property name="dist.base.source" value="${dist.base}/source"/>
  <property name="dist.base.binaries" value="${dist.base}/binaries"/>
  <property name="dist.base.manual" value="${dist.base}/manual"/>
  <property name="dist.dir" location="dist"/>
  <property name="dist.bin" value="${dist.dir}/bin"/>
  <property name="dist.lib" value="${dist.dir}/lib"/>
  <property name="dist.manual" value="${dist.dir}/manual"/>
  <property name="dist.etc" value="${dist.dir}/etc"/>
  <property name="dist.javadocs" value="${dist.dir}/manual/api"/>

  <property name="src.dist.dir" value="dist-src"/>
  <property name="src.dist.src" value="${src.dist.dir}/src"/>
  <property name="src.dist.manual" value="${src.dist.dir}/manual"/>
  <property name="src.dist.lib" value="${src.dist.dir}/lib"/>

  <property name="java-repository.dir" value="java-repository/${groupid}"/>

  <!--
       ===================================================================
         Set up selectors to be used by javac, junit and jar to exclude
         files that have dependencies that are not available
       ===================================================================
  -->

  <!-- Kaffe has some JDK 1.5 features including java.lang.Readable,
       but not all of them -->
  <selector id="not.in.kaffe">
    <or>
      <filename name="${condition.package}/IsReachable*"/>
    </or>
  </selector>

  <selector id="needs.apache-resolver">
    <filename name="${apache.resolver.type.package}/"/>
  </selector>

  <selector id="needs.junit">
    <and>
      <filename name="${optional.package}/junit/"/>
      <not>
          <or>
            <filename name="${optional.package}/junit/JUnit4TestMethodAdapter*"/>
            <filename name="${optional.package}/junit/CustomJUnit4TestAdapterCache*" />
          </or>
      </not>
    </and>
  </selector>

  <selector id="needs.junit4">
      <or>
         <filename name="${optional.package}/junit/JUnit4TestMethodAdapter*"/>
         <filename name="${optional.package}/junit/CustomJUnit4TestAdapterCache*" />
      </or>
  </selector>

  <selector id="needs.apache-regexp">
    <filename name="${regexp.package}/JakartaRegexp*"/>
  </selector>

  <selector id="needs.apache-oro">
    <or>
      <filename name="${regexp.package}/JakartaOro*"/>
    </or>
  </selector>

  <selector id="needs.apache-bcel">
    <or>
      <filename name="${ant.package}/filters/util/JavaClassHelper*"/>
      <filename name="${util.package}/depend/bcel/"/>
      <filename name="${optional.type.package}/depend/ClassFileSetTest*"/>
    </or>
  </selector>

  <selector id="needs.apache-log4j">
    <filename name="${ant.package}/listener/Log4jListener*"/>
  </selector>

  <selector id="needs.commons-logging">
    <filename name="${ant.package}/listener/CommonsLoggingListener*"/>
  </selector>

  <selector id="needs.apache-bsf">
    <or>
      <filename name="${util.package}/ScriptRunner.*"/>
      <filename name="${util.package}/optional/ScriptRunner*"/>
    </or>
  </selector>

  <selector id="needs.javamail">
    <or>
      <filename name="${ant.package}/taskdefs/email/MimeMailer*"/>
    </or>
  </selector>

  <selector id="needs.netrexx">
    <filename name="${optional.package}/NetRexxC*"/>
  </selector>

  <selector id="needs.commons-net">
    <or>
      <filename name="${optional.package}/net/FTP*"/>
      <filename name="${optional.package}/net/RExec*"/>
      <filename name="${optional.package}/net/TelnetTask*"/>
    </or>
  </selector>

  <selector id="needs.antlr">
    <filename name="${optional.package}/ANTLR*"/>
  </selector>

  <selector id="needs.jmf">
    <filename name="${optional.package}/sound/"/>
  </selector>

  <selector id="needs.jai">
    <or>
      <filename name="${optional.package}/image/"/>
      <filename name="${optional.type.package}/image/"/>
    </or>
  </selector>

  <selector id="needs.jdepend">
    <filename name="${optional.package}/jdepend/"/>
  </selector>

  <selector id="needs.swing">
    <filename name="${optional.package}/splash/"/>
  </selector>

  <selector id="needs.jsch">
    <filename name="${optional.package}/ssh/"/>
  </selector>

  <!-- needs TraceListenerEx3 interface implemented by PrintTraceListener -->
  <selector id="needs.apache-xalan2">
    <filename name="${optional.package}/Xalan2TraceSupport*"/>
  </selector>

  <selector id="needs.xz">
      <or>
         <filename name="${optional.package}/xz/"/>
         <filename name="${type.package}/optional/xz/"/>
      </or>
  </selector>

  <selector id="ant.launcher">
    <filename name="${ant.package}/launch/"/>
  </selector>

  <selector id="ant.core">
    <not>
      <or>
        <selector refid="needs.antlr"/>
        <selector refid="needs.apache-bcel"/>
        <selector refid="needs.apache-bsf"/>
        <selector refid="needs.apache-log4j"/>
        <selector refid="needs.apache-oro"/>
        <selector refid="needs.apache-regexp"/>
        <selector refid="needs.apache-resolver"/>
        <selector refid="needs.apache-xalan2"/>
        <selector refid="needs.commons-logging"/>
        <selector refid="needs.commons-net"/>
        <selector refid="needs.jai"/>
        <selector refid="needs.javamail"/>
        <selector refid="needs.jdepend"/>
        <selector refid="needs.jmf"/>
        <selector refid="needs.jsch"/>
        <selector refid="needs.junit"/>
        <selector refid="needs.junit4"/>
        <selector refid="needs.netrexx"/>
        <selector refid="needs.swing"/>
        <selector refid="needs.xz"/>
        <selector refid="ant.launcher"/>
      </or>
    </not>
  </selector>

  <patternset id="onlinetests">
    <exclude name="**/GetTest.java" if="offline"/>
    <exclude name="**/HttpTest.java" if="offline"/>
  </patternset>

  <patternset id="teststhatfail">
    <!-- Property 'run.failing.tests' should force Ant to run these tests. -->
    <!-- Because the whole patternset can not be excluded, you have to add -->
    <!-- an unless-attribute on each exclude-element.                      -->
    <exclude unless="run.failing.tests" name="${optional.package}/BeanShellScriptTest.java"/>
    <exclude unless="run.failing.tests" name="${optional.package}/jdepend/JDependTest.java"/>
  </patternset>

  <!--tests that need an XML Schema-supporting parser to work-->
  <selector id="needs.xmlschema">
    <or>
      <filename name="${optional.package}/SchemaValidateTest.*"/>
      <filename name="${optional.package}/XmlValidateTest.*"/>
    </or>
  </selector>

  <!--
       ===================================================================
         Set up a patternsets that matches the parts of our JUnit testsuite
         that may be useful for task developers.
       ===================================================================
  -->
  <patternset id="useful.tests">
    <include name="${ant.package}/AntAssert*"/>
    <include name="${ant.package}/BuildFileTest*"/>
    <include name="${ant.package}/BuildFileRule*"/>
    <include name="${ant.package}/FileUtilities*"/>
    <include name="${regexp.package}/RegexpMatcherTest*"/>
    <include name="${regexp.package}/RegexpTest*"/>
    <include name="${optional.package}/AbstractXSLTLiaisonTest*"/>
    <include name="${ant.package}/types/AbstractFileSetTest*"/>
  </patternset>

  <!--
       ===================================================================
         Check to see what optional dependencies are available
       ===================================================================
  -->
  <target name="check_for_optional_packages">
    <condition property="ignoresystemclasses">
      <not>
        <equals arg1="${build.sysclasspath}" arg2="only"/>
      </not>
    </condition>
    <property name="ignoresystemclasses" value="false"/>
    <available property="jdk9+" classname="java.lang.module.ModuleDescriptor"/>
    <available property="kaffe" classname="kaffe.util.NotImplemented"/>
    <available property="harmony"
               classname="org.apache.harmony.luni.util.Base64"/>
    <available property="bsf.present"
      classname="org.apache.bsf.BSFManager"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
    <available property="netrexx.present"
      classname="netrexx.lang.Rexx"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
    <available property="apache.resolver.present"
      classname="org.apache.xml.resolver.tools.CatalogResolver"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
    <available property="recent.xalan2.present"
      classname="org.apache.xalan.trace.TraceListenerEx3"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
    <available property="junit.present"
      classname="junit.framework.TestCase"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
    <available property="junit4.present"
      classname="org.junit.Test"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
    <available property="antunit.present"
      classname="org.apache.ant.antunit.AntUnit"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
    <available property="commons.net.present"
      classname="org.apache.commons.net.ftp.FTPClient"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
    <available property="antlr.present" 
      classname="antlr.Tool" 
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
    <available property="apache.regexp.present"
      classname="org.apache.regexp.RE"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
    <available property="apache.oro.present"
      classname="org.apache.oro.text.regex.Perl5Matcher"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
    <available property="jmf.present"
      classname="javax.sound.sampled.Clip"
      classpathref="classpath"/>
    <available property="jai.present"
      classname="javax.media.jai.JAI"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
    <available property="jdepend.present"
      classname="jdepend.framework.JDepend"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
    <available property="log4j.present"
      classname="org.apache.log4j.Logger"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
    <available property="commons.logging.present"
      classname="org.apache.commons.logging.LogFactory"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
    <available property="xalan.envcheck"
      classname="org.apache.xalan.xslt.EnvironmentCheck"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
    <available property="which.present"
      classname="org.apache.env.Which"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>

    <available property="xerces.present"
      classname="org.apache.xerces.parsers.SAXParser"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
    <available property="bcel.present"
      classname="org.apache.bcel.Constants"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>

    <condition property="javamail.complete">
      <and>
        <available classname="javax.activation.DataHandler"
          classpathref="classpath"/>
        <available classname="javax.mail.Transport"
          classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
      </and>
    </condition>

    <condition property="tests.and.ant.share.classloader">
      <or>
        <equals arg1="${junit.fork}" arg2="true"/>
        <equals arg1="${build.sysclasspath}" arg2="only"/>
      </or>
    </condition>

    <condition property="sun.tools.present">
      <and>
        <available classname="sun.tools.native2ascii.Main"/>
        <available classname="com.sun.tools.javah.Main"/>
      </and>
    </condition>

    <condition property="tests.are.on.system.classpath">
      <or>
        <resourcecount count="1">
          <intersect>
            <path path="${java.class.path}" />
            <file file="${build.tests}" />
          </intersect>
        </resourcecount>
        <istrue value="${junit.fork}"/>
      </or>
    </condition>

    <echo level="verbose"> tests.are.on.system.classpath=${tests.are.on.system.classpath}</echo>

    <condition property="jasper.present">
      <and>
        <available classname="org.apache.jasper.compiler.Compiler"/>
        <available classname="org.apache.jasper.JasperException"/>
      </and>
    </condition>

    <condition property="swing.present">
      <or>
        <not>
          <isset property="kaffe"/>
        </not>
        <available classname="javax.swing.ImageIcon"
          classpathref="classpath"/>
      </or>
    </condition>

    <available property="rhino.present"
      classname="org.mozilla.javascript.Scriptable"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
    <available property="beanshell.present"
      classname="bsh.StringUtil"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
    <available property="xerces1.present"
      classname="org.apache.xerces.framework.XMLParser"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
    <available property="jsch.present"
      classname="com.jcraft.jsch.Session"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>
    <available property="xz.present"
      classname="org.tukaani.xz.XZOutputStream"
      classpathref="classpath" ignoresystemclasses="${ignoresystemclasses}"/>

    <property name="build.compiler" value="modern"/>

    <!--check for XSD support in the parser-->
    <condition property="xmlschema.present">
      <or>
        <parsersupports
          feature="http://apache.org/xml/features/validation/schema"/>
        <parsersupports
          feature="http://java.sun.com/xml/jaxp/properties/schemaSource"/>
      </or>
    </condition>

    <!-- 
    Java8 introduced a HTML checker 'doclint' which is very strict and breaks 
    the build if there is a HTML error in the JavaDoc.
    -->
    <condition 
      property="javadoc.doclint.none" 
      value="-Xdoclint:none" 
      else="">
      <not><isset property="withDoclint"/></not>
    </condition>
  </target>


  <!--
       ===================================================================
         Prepare the build
       ===================================================================
  -->
  <target name="prepare">
    <tstamp>
      <format property="year" pattern="yyyy"/>
    </tstamp>
    <filterchain id="ant.filters">
       <expandproperties/>
    </filterchain>
  </target>

  <!--
       ===================================================================
         Build the code
       ===================================================================
  -->
  <target name="build"
    depends="prepare, check_for_optional_packages"
    description="--> compiles the source code">
    <mkdir dir="${build.dir}"/>
    <mkdir dir="${build.classes}"/>
    <mkdir dir="${build.lib}"/>

    <javac srcdir="${java.dir}"
      includeantruntime="false"
      destdir="${build.classes}"
      debug="${debug}"
      deprecation="${deprecation}"
      target="${javac.target}"
      source="${javac.source}"
      optimize="${optimize}">
      <classpath refid="classpath"/>

      <selector id="conditional-patterns">
        <not>
          <or>
            <selector refid="not.in.kaffe" if="kaffe"/>

            <selector refid="needs.apache-resolver" unless="apache.resolver.present"/>
            <selector refid="needs.junit" unless="junit.present"/> <!-- TODO should perhaps use -source 1.4? -->
            <selector refid="needs.junit4" unless="junit4.present"/>
            <selector refid="needs.apache-regexp"
              unless="apache.regexp.present"/>
            <selector refid="needs.apache-oro" unless="apache.oro.present"/>
            <selector refid="needs.apache-bcel" unless="bcel.present"/>
            <selector refid="needs.apache-log4j" unless="log4j.present"/>
            <selector refid="needs.commons-logging"
              unless="commons.logging.present"/>
            <selector refid="needs.apache-bsf" unless="bsf.present"/>
            <selector refid="needs.javamail" unless="javamail.complete"/>
            <selector refid="needs.netrexx" unless="netrexx.present"/>
            <selector refid="needs.commons-net" unless="commons.net.present"/>
            <selector refid="needs.antlr" unless="antlr.present"/>
            <selector refid="needs.jmf" unless="jmf.present"/>
            <selector refid="needs.jai" unless="jai.present"/>
            <selector refid="needs.jdepend" unless="jdepend.present"/>
            <selector refid="needs.swing" unless="swing.present"/>
            <selector refid="needs.jsch" unless="jsch.present"/>
            <selector refid="needs.xz" unless="xz.present"/>
            <selector refid="needs.xmlschema" unless="xmlschema.present"/>
            <selector refid="needs.apache-xalan2"
                      unless="recent.xalan2.present"/>
          </or>
        </not>
      </selector>
    </javac>

    <copy todir="${build.classes}">
      <fileset dir="${java.dir}">
        <include name="**/*.properties"/>
        <include name="**/*.dtd"/>
        <include name="**/*.xml"/>
      </fileset>
      <fileset dir="${resource.dir}" />
    </copy>

    <copy todir="${build.classes}"
      overwrite="true" encoding="UTF-8">
      <fileset dir="${java.dir}">
        <include name="**/version.txt"/>
        <include name="**/defaultManifest.mf"/>
      </fileset>
      <filterchain refid="ant.filters"/>
    </copy>

    <copy todir="${build.classes}/${optional.package}/junit/xsl">
      <fileset dir="${etc.dir}">
        <include name="junit-frames.xsl"/>
        <include name="junit-noframes.xsl"/>
      </fileset>
    </copy>
  </target>

  <!--
       ===================================================================
         Create the all of the Apache Ant jars
       ===================================================================
  -->
  <target name="jars"
    depends="build"
    description="--> creates the Apache Ant jars">

    <copy todir="${build.dir}">
      <fileset dir="${basedir}">
        <include name="LICENSE"/>
        <include name="LICENSE.xerces"/>
        <include name="LICENSE.dom"/>
        <include name="LICENSE.sax"/>
        <include name="NOTICE"/>
      </fileset>
      <mapper type="glob" from="*" to="*.txt"/>
    </copy>

    <copy file="${manifest}" tofile="${manifest.tmp}"/>
    <manifest file="${manifest.tmp}">
      <section name="${optional.package}/">
        <attribute name="Extension-name"
          value="org.apache.tools.ant"/>
        <attribute name="Specification-Title"
          value="Apache Ant"/>
        <attribute name="Specification-Version"
          value="${manifest-version}"/>
        <attribute name="Specification-Vendor"
          value="Apache Software Foundation"/>
        <attribute name="Implementation-Title"
          value="org.apache.tools.ant"/>
        <attribute name="Implementation-Version"
          value="${manifest-version}"/>
        <attribute name="Implementation-Vendor"
          value="Apache Software Foundation"/>
      </section>
    </manifest>

    <jar destfile="${build.lib}/${name}-launcher.jar"
      basedir="${build.classes}"
      whenmanifestonly="fail">
      <selector refid="ant.launcher"/>
      <metainf dir="${build.dir}">
        <include name="LICENSE.txt"/>
        <include name="NOTICE.txt"/>
      </metainf>
      <manifest>
        <attribute name="Main-Class" value="org.apache.tools.ant.launch.Launcher"/>
      </manifest>
    </jar>

    <jar destfile="${build.lib}/${name}.jar"
      basedir="${build.classes}"
      manifest="${manifest}"
      whenmanifestonly="fail">
      <!-- Verification: (cd dist/lib; for j in *.jar; do jar tf $j; done) | egrep -v '/$|META-INF/MANIFEST\.MF' | sort | uniq -d -->
      <selector refid="ant.core"/>
      <metainf dir="${build.dir}">
        <include name="LICENSE.txt"/>
        <include name="NOTICE.txt"/>
      </metainf>

      <manifest>
        <section name="${ant.package}/">
          <attribute name="Extension-name"
            value="org.apache.tools.ant"/>
          <attribute name="Specification-Title"
            value="Apache Ant"/>
          <attribute name="Specification-Version"
            value="${manifest-version}"/>
          <attribute name="Specification-Vendor"
            value="Apache Software Foundation"/>
          <attribute name="Implementation-Title"
            value="org.apache.tools.ant"/>
          <attribute name="Implementation-Version"
            value="${manifest-version}"/>
          <attribute name="Implementation-Vendor"
            value="Apache Software Foundation"/>
        </section>
      </manifest>

      <fileset dir="${manual.dir}">
        <include name="images/ant_logo_large.gif"/>
      </fileset>
    </jar>

    <jar destfile="${build.lib}/${bootstrap.jar}"
      basedir="${build.classes}"
      manifest="${manifest}"
      whenmanifestonly="fail">
      <include name="${ant.package}/Main.class"/>
      <metainf dir="${build.dir}">
        <include name="LICENSE.txt"/>
        <include name="NOTICE.txt"/>
      </metainf>
      <manifest>
        <attribute name="Class-Path"
          value="ant.jar xalan.jar"/>
      </manifest>
    </jar>

    <macrodef name="optional-jar">
      <attribute name="dep"/>
      <sequential>
        <jar destfile="${build.lib}/${optional.jars.prefix}-@{dep}.jar"
          basedir="${build.classes}"
          manifest="${manifest.tmp}"
          whenmanifestonly="${optional.jars.whenmanifestonly}">
          <selector refid="needs.@{dep}"/>
          <metainf dir="${build.dir}">
            <include name="LICENSE.txt"/>
            <include name="NOTICE.txt"/>
          </metainf>
        </jar>
      </sequential>
    </macrodef>

    <optional-jar dep="apache-resolver"/>
    <optional-jar dep="junit"/>
    <optional-jar dep="junit4"/>
    <optional-jar dep="apache-regexp"/>
    <optional-jar dep="apache-oro"/>
    <optional-jar dep="apache-bcel"/>
    <optional-jar dep="apache-log4j"/>
    <optional-jar dep="commons-logging"/>
    <optional-jar dep="apache-bsf"/>
    <optional-jar dep="javamail"/>
    <optional-jar dep="netrexx"/>
    <optional-jar dep="commons-net"/>
    <optional-jar dep="antlr"/>
    <optional-jar dep="jmf"/>
    <optional-jar dep="jai"/>
    <optional-jar dep="swing"/>
    <optional-jar dep="jsch"/>
    <optional-jar dep="jdepend"/>
    <optional-jar dep="apache-xalan2"/>
    <optional-jar dep="xz"/>

  </target>

  <!--   Creates jar of test utility classes -->
  <target name="test-jar"
    depends="compile-tests"
    description="--> creates the Apache Ant Test Utilities jar">

    <fail unless="junit.present">
      We cannot build the test jar unless JUnit is present,
      as JUnit is needed to compile the test classes.
    </fail>
    <jar destfile="${build.lib}/${name}-testutil.jar"
      basedir="${build.tests}">
      <patternset refid="useful.tests"/>
      <metainf dir="${build.dir}">
        <include name="LICENSE.txt"/>
        <include name="NOTICE.txt"/>
      </metainf>
    </jar>
  </target>

  <!--
       ===================================================================
         Create the all of the Apache Ant source jars
       ===================================================================
  -->
  <target name="jars-sources" description="--> creates the Apache Ant source jars">
    <mkdir dir="${build.lib-src}" />
    <jar destfile="${build.lib-src}/${name}-launcher.jar"
      basedir="${java.dir}"
      whenmanifestonly="fail">
      <selector refid="ant.launcher"/>
      <metainf dir="${build.dir}">
        <include name="LICENSE.txt"/>
        <include name="NOTICE.txt"/>
      </metainf>
    </jar>

    <jar destfile="${build.lib-src}/${name}.jar"
      basedir="${java.dir}"
      whenmanifestonly="fail">
      <selector refid="ant.core"/>
      <metainf dir="${build.dir}">
        <include name="LICENSE.txt"/>
        <include name="NOTICE.txt"/>
      </metainf>
    </jar>

    <jar destfile="${build.lib-src}/${bootstrap.jar}"
      basedir="${java.dir}"
      whenmanifestonly="fail">
      <include name="${ant.package}/Main.java"/>
      <metainf dir="${build.dir}">
        <include name="LICENSE.txt"/>
        <include name="NOTICE.txt"/>
      </metainf>
    </jar>

    <macrodef name="optional-src-jar">
      <attribute name="dep"/>
      <sequential>
        <jar destfile="${build.lib-src}/${optional.jars.prefix}-@{dep}.jar"
          basedir="${java.dir}"
          whenmanifestonly="${optional.jars.whenmanifestonly}">
          <selector refid="needs.@{dep}"/>
          <metainf dir="${build.dir}">
            <include name="LICENSE.txt"/>
            <include name="NOTICE.txt"/>
          </metainf>
        </jar>
      </sequential>
    </macrodef>

    <optional-src-jar dep="apache-resolver"/>
    <optional-src-jar dep="junit"/>
    <optional-src-jar dep="junit4"/>
    <optional-src-jar dep="apache-regexp"/>
    <optional-src-jar dep="apache-oro"/>
    <optional-src-jar dep="apache-bcel"/>
    <optional-src-jar dep="apache-log4j"/>
    <optional-src-jar dep="commons-logging"/>
    <optional-src-jar dep="apache-bsf"/>
    <optional-src-jar dep="javamail"/>
    <optional-src-jar dep="netrexx"/>
    <optional-src-jar dep="commons-net"/>
    <optional-src-jar dep="antlr"/>
    <optional-src-jar dep="jmf"/>
    <optional-src-jar dep="jai"/>
    <optional-src-jar dep="swing"/>
    <optional-src-jar dep="jsch"/>
    <optional-src-jar dep="jdepend"/>
    <optional-src-jar dep="apache-xalan2"/>
    <optional-src-jar dep="xz"/>

  </target>

  <target name="test-jar-source"
    description="--> creates the Apache Ant Test Utilities source jar">
    <mkdir dir="${build.lib-src}" />
    <jar destfile="${build.lib-src}/${name}-testutil.jar"
      basedir="${java.dir}">
      <patternset refid="useful.tests" />
      <metainf dir="${build.dir}">
        <include name="LICENSE.txt"/>
        <include name="NOTICE.txt"/>
      </metainf>
    </jar>
  </target>

  <!--
       ===================================================================
         Create the essential distribution that can run Apache Ant
       ===================================================================
  -->
  <target name="dist-lite"
    depends="jars,test-jar"
    description="--> creates a minimum distribution to run Apache Ant">

    <mkdir dir="${dist.dir}"/>
    <mkdir dir="${dist.bin}"/>
    <mkdir dir="${dist.lib}"/>

    <copy todir="${dist.lib}">
      <fileset dir="${build.lib}">
        <exclude name="${bootstrap.jar}"/>
      </fileset>
    </copy>

    <copy todir="${dist.lib}">
      <fileset dir="${lib.dir}">
        <include name="*.jar"/>
        <include name="*.zip"/>
      </fileset>
    </copy>

    <copy todir="${dist.bin}">
      <fileset dir="${script.dir}"/>
    </copy>

    <fixcrlf srcdir="${dist.bin}" eol="dos" includes="*.bat,*.cmd"/>
    <fixcrlf srcdir="${dist.bin}" eol="unix">
      <include name="ant"/>
      <include name="antRun"/>
      <include name="*.pl"/>
    </fixcrlf>

    <setpermissions mode="755" failonerror="${setpermissions.fail}"
                    nonPosixMode="${setpermissions.nonposixmode}">
      <dirset dir="${dist.dir}"/>
    </setpermissions>
    <setpermissions mode="644" failonerror="${setpermissions.fail}"
                    nonPosixMode="${setpermissions.nonposixmode}">
      <fileset dir="${dist.dir}"/>
    </setpermissions>
    <setpermissions mode="755" failonerror="${setpermissions.fail}"
                    nonPosixMode="${setpermissions.nonposixmode}">
      <fileset dir="${dist.bin}">
        <include name="**/ant"/>
        <include name="**/antRun"/>
        <include name="**/*.pl"/>
        <include name="**/*.py"/>
      </fileset>
    </setpermissions>

  </target>

  <!--
        ===================================================================
          Create the complete distribution
        ===================================================================
   -->
  <target name="dist" description="--> creates a complete distribution">
    <antcall inheritAll="false" target="internal_dist">
      <param name="dist.dir" value="${dist.name}"/>
    </antcall>
  </target>

  <target name="dist_javadocs" depends="javadocs" unless="javadoc.notrequired">
    <mkdir dir="${dist.javadocs}"/>
    <copy todir="${dist.javadocs}" overwrite="true">
      <fileset dir="${build.javadocs}"/>
    </copy>
  </target>


  <macrodef name="checksums-mvn" description="only md5 and sha1 are needed for the maven directory structure">
    <element name="resources" implicit="true"/>
    <sequential>
      <checksum algorithm="md5">
        <resources/>
      </checksum>
      <checksum algorithm="sha1">
        <resources/>
      </checksum>
    </sequential>
  </macrodef>
  <macrodef name="checksums">
    <element name="resources" implicit="true"/>
    <sequential>
      <checksums-mvn>
        <resources/>
      </checksums-mvn>
      <checksum fileext=".sha512" algorithm="sha-512">
        <resources/>
      </checksum>
    </sequential>
  </macrodef>

  <target name="internal_dist" depends="dist-lite,dist_javadocs">
    <mkdir dir="${dist.manual}"/>
    <mkdir dir="${dist.etc}"/>

    <copy todir="${dist.lib}" file="${lib.dir}/README"/>
    <copy todir="${dist.lib}" file="${lib.dir}/libraries.properties"/>

    <copy todir="${dist.lib}">
        <fileset dir="${src.dir}/etc/poms">
            <include name="*/pom.xml"/>
        </fileset>
        <mapper type="regexp" from="^(.*)[/\\]pom.xml" to="\1.pom"/>
        <filterchain>
            <tokenfilter>
                <replaceregex pattern="${pom.version}" replace="${project.version}"/>
            </tokenfilter>
        </filterchain>
    </copy>
    <copy todir="${dist.lib}">
        <fileset dir="${src.dir}/etc/poms">
            <include name="pom.xml"/>
        </fileset>
        <mapper type="glob" from="pom.xml" to="ant-parent.pom"/>
        <filterchain>
            <tokenfilter>
                <replaceregex pattern="${pom.version}" replace="${project.version}"/>
            </tokenfilter>
        </filterchain>
    </copy>


    <copy todir="${dist.manual}">
      <fileset dir="${manual.dir}" />
    </copy>

    <copy todir="${dist.dir}">
      <fileset dir="${basedir}">
        <include name="CONTRIBUTORS"/>
        <include name="README"/>
        <include name="INSTALL"/>
        <include name="LICENSE"/>
        <include name="LICENSE.xerces"/>
        <include name="LICENSE.dom"/>
        <include name="LICENSE.sax"/>
        <include name="NOTICE"/>
        <include name="TODO"/>
        <include name="WHATSNEW"/>
        <include name="KEYS"/>
        <include name="contributors.xml"/>
        <include name="fetch.xml"/>
        <include name="get-m2.xml"/>
        <include name="patch.xml"/>
      </fileset>
    </copy>

    <setpermissions mode="755" failonerror="${setpermissions.fail}"
                    nonPosixMode="${setpermissions.nonposixmode}">
      <dirset dir="${dist.dir}"/>
    </setpermissions>
    <setpermissions mode="644" failonerror="${setpermissions.fail}"
                    nonPosixMode="${setpermissions.nonposixmode}">
      <fileset dir="${dist.dir}"/>
    </setpermissions>
    <setpermissions mode="755" failonerror="${setpermissions.fail}"
                    nonPosixMode="${setpermissions.nonposixmode}">
      <fileset dir="${dist.bin}">
        <include name="**/ant"/>
        <include name="**/antRun"/>
        <include name="**/*.pl"/>
        <include name="**/*.py"/>
      </fileset>
    </setpermissions>

    <!-- publish some useful stylesheets -->
    <copy todir="${dist.etc}">
      <fileset dir="${etc.dir}">
        <include name="junit-frames.xsl"/>
        <include name="junit-noframes.xsl"/>
        <include name="junit-frames-xalan1.xsl"/>
        <include name="coverage-frames.xsl"/>
        <include name="maudit-frames.xsl"/>
        <include name="mmetrics-frames.xsl"/>
        <include name="changelog.xsl"/>
        <include name="jdepend.xsl"/>
        <include name="jdepend-frames.xsl"/>
        <include name="checkstyle/*.xsl"/>
        <include name="log.xsl"/>
        <include name="tagdiff.xsl"/>
      </fileset>
      <fileset dir="${build.lib}">
        <include name="${bootstrap.jar}"/>
      </fileset>
    </copy>

  </target>


  <!--
       ===================================================================
         Target to create bootstrap build
       ===================================================================
  -->
  <target name="bootstrap" description="--> creates a bootstrap build">
    <antcall inheritAll="false" target="dist-lite">
      <param name="dist.dir" value="${bootstrap.dir}"/>
    </antcall>
  </target>


  <!--
       ===================================================================
         Create the source distribution
       ===================================================================
  -->
  <target name="src-dist"
    description="--> creates a source distribution">

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

    <copy todir="${src.dist.lib}">
      <fileset dir="${lib.dir}">
        <include name="optional/junit*.jar"/>
        <include name="optional/hamcrest*.jar"/>
        <include name="README"/>
        <include name="libraries.properties"/>
      </fileset>
    </copy>

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

    <copy todir="${src.dist.src}">
      <fileset dir="${src.dir}"/>
    </copy>

    <copy todir="${src.dist.manual}">
      <fileset dir="${manual.dir}">
        <exclude name="api/"/>
      </fileset>
    </copy>

    <copy todir="${src.dist.dir}">
      <fileset dir="${basedir}">
        <include name="CONTRIBUTORS"/>
        <include name="INSTALL"/>
        <include name="KEYS"/>
        <include name="LICENSE"/>
        <include name="LICENSE.dom"/>
        <include name="LICENSE.sax"/>
        <include name="LICENSE.xerces"/>
        <include name="NOTICE"/>
        <include name="README"/>
        <include name="TODO"/>
        <include name="WHATSNEW"/>
        <include name="bootstrap.bat"/>
        <include name="bootstrap.sh"/>
        <include name="build.bat"/>
        <include name="build.sh"/>
        <include name="build.xml"/>
        <include name="contributors.xml"/>
        <include name="fetch.xml"/>
        <include name="get-m2.xml"/>
        <include name="patch.xml"/>
      </fileset>
    </copy>

    <fixcrlf srcdir="${src.dist.dir}" eol="dos" includes="*.bat,*.cmd"/>
    <fixcrlf srcdir="${src.dist.dir}" eol="unix">
      <include name="**/*.sh"/>
      <include name="**/*.pl"/>
      <include name="**/ant"/>
      <include name="**/antRun"/>
    </fixcrlf>
    <fixcrlf srcdir="${src.dist.dir}">
      <include name="**/*.java"/>
      <exclude name="${tests.etc.dir}/taskdefs/fixcrlf/expected/Junk?.java"/>
      <exclude name="${tests.etc.dir}/taskdefs/fixcrlf/input/Junk?.java"/>
    </fixcrlf>

    <setpermissions mode="755" failonerror="${setpermissions.fail}"
                    nonPosixMode="${setpermissions.nonposixmode}">
      <dirset dir="${src.dist.dir}"/>
    </setpermissions>
    <setpermissions mode="644" failonerror="${setpermissions.fail}"
                    nonPosixMode="${setpermissions.nonposixmode}">
      <fileset dir="${src.dist.dir}"/>
    </setpermissions>
    <setpermissions mode="755" failonerror="${setpermissions.fail}"
                    nonPosixMode="${setpermissions.nonposixmode}">
      <fileset dir="${src.dist.dir}">
        <include name="**/*.sh"/>
        <include name="**/*.pl"/>
        <include name="**/*.py"/>
        <include name="**/ant"/>
        <include name="**/antRun"/>
      </fileset>
    </setpermissions>

  </target>

  <!--
       ===================================================================
         Create the binary distribution
       ===================================================================
  -->
  <target name="-distribution_prep">
    <delete dir="${dist.base}"/>
    <delete dir="${dist.name}"/>
    <delete dir="${java-repository.dir}"/>
    <mkdir dir="${dist.base}"/>
    <mkdir dir="${dist.base.source}"/>
    <mkdir dir="${dist.base.binaries}"/>
    <mkdir dir="${dist.base.manual}"/>
    <mkdir dir="${java-repository.dir}"/>
    <antcall inheritAll="false" target="internal_dist">
      <param name="dist.dir" value="${dist.name}"/>
    </antcall>
  </target>

  <target name="zip_distribution" depends="jars,-distribution_prep"
    description="--> creates the zip distribution">
    <zip destfile="${dist.base.binaries}/${dist.name}-bin.zip">
      <zipfileset dir="${dist.name}/.." filemode="755">
        <include name="${dist.name}/bin/ant"/>
        <include name="${dist.name}/bin/antRun"/>
        <include name="${dist.name}/bin/*.pl"/>
        <include name="${dist.name}/bin/*.py"/>
      </zipfileset>
      <fileset dir="${dist.name}/..">
        <include name="${dist.name}/"/>
        <exclude name="${dist.name}/bin/ant"/>
        <exclude name="${dist.name}/bin/antRun"/>
        <exclude name="${dist.name}/bin/*.pl"/>
        <exclude name="${dist.name}/bin/*.py"/>
      </fileset>
    </zip>
  </target>

  <condition property="buildosxpackage">
    <and>
       <os family="mac"/>
       <isset property="buildosxpackage.required"/>
    </and>
  </condition>

  <target name="pkg_distribution" depends="zip_distribution" if="buildosxpackage">
    <exec executable="release/build-osx-pkg.py">
      <arg value="--output-dir"/>
      <arg value="${dist.base.binaries}"/>
      <arg value="${dist.base.binaries}/${dist.name}-bin.zip"/>
    </exec>
  </target>

  <target name="tar_distribution" depends="jars,-distribution_prep"
    description="--> creates the tar distribution">
    <tar longfile="gnu"
      destfile="${dist.base.binaries}/${dist.name}-bin.tar">
      <!-- removes redundant definition of permissions, but seems to
           drop dirs (and to be slow)
      <zipfileset src="${dist.base.binaries}/${dist.name}-bin.zip"/>
      -->
      <tarfileset dir="${dist.name}/.." mode="755" username="ant" group="ant">
        <include name="${dist.name}/bin/ant"/>
        <include name="${dist.name}/bin/antRun"/>
        <include name="${dist.name}/bin/*.pl"/>
        <include name="${dist.name}/bin/*.py"/>
      </tarfileset>
      <tarfileset dir="${dist.name}/.." username="ant" group="ant">
        <include name="${dist.name}/"/>
        <exclude name="${dist.name}/bin/ant"/>
        <exclude name="${dist.name}/bin/antRun"/>
        <exclude name="${dist.name}/bin/*.pl"/>
        <exclude name="${dist.name}/bin/*.py"/>
      </tarfileset>
    </tar>
    <gzip destfile="${dist.base.binaries}/${dist.name}-bin.tar.gz"
      src="${dist.base.binaries}/${dist.name}-bin.tar"/>
    <bzip2 destfile="${dist.base.binaries}/${dist.name}-bin.tar.bz2"
      src="${dist.base.binaries}/${dist.name}-bin.tar"/>
    <xz destfile="${dist.base.binaries}/${dist.name}-bin.tar.xz"
      src="${dist.base.binaries}/${dist.name}-bin.tar"/>
    <delete file="${dist.base.binaries}/${dist.name}-bin.tar"/>
  </target>

  <target name="main_distribution" depends="zip_distribution,pkg_distribution,tar_distribution,jars-sources,test-jar-source"
    description="--> creates the zip, pkg, and tar distributions">

    <copy todir="${java-repository.dir}">
      <fileset dir="${dist.name}/lib">
        <include name="ant*.jar"/>
      </fileset>
      <mapper type="regexp" from="ant(.*).jar" to="ant\1/${project.version}/ant\1-${project.version}.jar"/>
    </copy>
    <copy todir="${java-repository.dir}">
      <fileset dir="${dist.name}/lib">
        <include name="*.pom"/>
      </fileset>
      <mapper>
        <mapper type="regexp" from="ant(.*).pom" to="ant\1/${project.version}/ant\1-${project.version}.pom"/>
      </mapper>
    </copy>
    <copy todir="${java-repository.dir}">
      <fileset dir="${build.lib-src}">
        <include name="ant*.jar"/>
      </fileset>
      <mapper type="regexp" from="ant(.*).jar" to="ant\1/${project.version}/ant\1-${project.version}-sources.jar"/>
    </copy>
    <jar destfile="${java-repository.dir}/ant/${project.version}/ant-${project.version}-javadoc.jar"
      basedir="${build.javadocs}">
      <metainf dir="${build.dir}">
        <include name="LICENSE.txt"/>
        <include name="NOTICE.txt"/>
      </metainf>
    </jar>
    <checksums-mvn>
      <fileset dir="${java-repository.dir}" includes="**/*${project.version}.jar"/>
      <fileset dir="${java-repository.dir}" includes="**/*${project.version}-sources.jar"/>
      <fileset dir="${java-repository.dir}" includes="**/*${project.version}-javadoc.jar"/>
      <fileset dir="${java-repository.dir}" includes="**/*${project.version}.pom"/>
    </checksums-mvn>

    <zip destfile="${dist.base.manual}/${dist.name}-manual.zip">
      <zipfileset dir="${dist.name}/manual" prefix="${dist.name}"/>
      <zipfileset file="NOTICE" prefix="${dist.name}"/>
    </zip>
    <tar longfile="gnu"
         destfile="${dist.base.manual}/${dist.name}-manual.tar">
      <tarfileset dir="${dist.name}/manual" prefix="${dist.name}"/>
      <tarfileset file="NOTICE" prefix="${dist.name}"/>
    </tar>
    <gzip destfile="${dist.base.manual}/${dist.name}-manual.tar.gz"
          src="${dist.base.manual}/${dist.name}-manual.tar"/>
    <bzip2 destfile="${dist.base.manual}/${dist.name}-manual.tar.bz2"
           src="${dist.base.manual}/${dist.name}-manual.tar"/>
    <xz destfile="${dist.base.manual}/${dist.name}-manual.tar.xz"
           src="${dist.base.manual}/${dist.name}-manual.tar"/>
    <delete file="${dist.base.manual}/${dist.name}-manual.tar"/>

    <delete dir="${dist.name}"/>
    <checksums>
      <fileset dir="${dist.base.binaries}/">
        <exclude name="**/*.asc"/>
        <exclude name="**/*.md5"/>
        <exclude name="**/*.sha1"/>
        <exclude name="**/*.sha512"/>
      </fileset>
      <fileset dir="${dist.base.manual}/">
        <exclude name="**/*.asc"/>
        <exclude name="**/*.md5"/>
        <exclude name="**/*.sha1"/>
        <exclude name="**/*.sha512"/>
      </fileset>
    </checksums>

    <antcall inheritAll="false" target="src-dist">
      <param name="src.dist.dir" value="${dist.name}"/>
    </antcall>
    <zip destfile="${dist.base.source}/${dist.name}-src.zip">
      <zipfileset dir="${dist.name}/.." filemode="755">
        <include name="${dist.name}/bootstrap.sh"/>
        <include name="${dist.name}/build.sh"/>
      </zipfileset>
      <fileset dir="${dist.name}/..">
        <include name="${dist.name}/"/>
        <exclude name="${dist.name}/bootstrap.sh"/>
        <exclude name="${dist.name}/build.sh"/>
      </fileset>
    </zip>
    <tar longfile="gnu"
      destfile="${dist.base.source}/${dist.name}-src.tar">
      <!--
      <zipfileset src="${dist.base.source}/${dist.name}-src.zip"/>
      -->
      <tarfileset dir="${dist.name}/.." mode="755" username="ant" group="ant">
        <include name="${dist.name}/bootstrap.sh"/>
        <include name="${dist.name}/build.sh"/>
      </tarfileset>
      <tarfileset dir="${dist.name}/.." username="ant" group="ant">
        <include name="${dist.name}/"/>
        <exclude name="${dist.name}/bootstrap.sh"/>
        <exclude name="${dist.name}/build.sh"/>
      </tarfileset>
    </tar>
    <gzip destfile="${dist.base.source}/${dist.name}-src.tar.gz"
      src="${dist.base.source}/${dist.name}-src.tar"/>
    <bzip2 destfile="${dist.base.source}/${dist.name}-src.tar.bz2"
      src="${dist.base.source}/${dist.name}-src.tar"/>
    <xz destfile="${dist.base.source}/${dist.name}-src.tar.xz"
      src="${dist.base.source}/${dist.name}-src.tar"/>
    <delete file="${dist.base.source}/${dist.name}-src.tar"/>
    <delete dir="${dist.name}"/>
    <checksums>
      <fileset dir="${dist.base.source}/">
        <exclude name="**/*.asc"/>
        <exclude name="**/*.md5"/>
        <exclude name="**/*.sha1"/>
        <exclude name="**/*.sha512"/>
      </fileset>
    </checksums>
  </target>

  <target name="distribution" depends="main_distribution"
    description="--> creates the full Apache Ant distribution">
  </target>

  <!--
       ===================================================================
         Cleans up build and distribution directories
       ===================================================================
  -->
  <target name="clean"
    description="--> cleans up build and dist directories">
    <delete dir="${build.dir}"/>
    <delete dir="${dist.base}"/>
    <delete dir="${dist.dir}"/>
    <delete>
      <fileset dir="." includes="**/*~" defaultexcludes="no"/>
    </delete>
  </target>

  <!--
       ===================================================================
         Cleans everything
       ===================================================================
  -->
  <target name="allclean"
    depends="clean"
    description="--> cleans up everything">
    <delete file="${bootstrap.dir}/bin/antRun"/>
    <delete file="${bootstrap.dir}/bin/antRun.bat"/>
    <delete file="${bootstrap.dir}/bin/*.pl"/>
    <delete file="${bootstrap.dir}/bin/*.py"/>
  </target>

  <!--
       ===================================================================
         Installs Apache Ant
       ===================================================================
  -->
  <target name="install">
    <fail message="You must set the property ant.install=/where/to/install" unless="ant.install"/>
    <antcall inheritAll="false" target="internal_dist">
      <param name="dist.dir" value="${ant.install}"/>
    </antcall>
  </target>

  <target name="install-lite">
    <fail message="You must set the property ant.install=/where/to/install" unless="ant.install"/>
    <antcall inheritAll="false" target="dist-lite">
      <param name="dist.dir" value="${ant.install}"/>
    </antcall>
  </target>

  <!--
       ===================================================================
         Creates the API documentation
       ===================================================================
  -->
  <target name="javadoc_check">
    <uptodate property="javadoc.notrequired"
      targetfile="${build.javadocs}/packages.html">
      <srcfiles dir="${java.dir}" includes="**/*.java"/>
    </uptodate>
    <uptodate property="tests.javadoc.notrequired"
      targetfile="${build.tests.javadocs}/packages.html">
      <srcfiles dir="${src.junit}">
        <patternset refid="useful.tests"/>
      </srcfiles>
    </uptodate>
  </target>

  <target name="javadocs" depends="prepare, javadoc_check, check_for_optional_packages"
    description="--> creates the API documentation" unless="javadoc.notrequired">
    <mkdir dir="${build.javadocs}"/>
    <javadoc useexternalfile="yes"
      maxmemory="1000M" 
      destdir="${build.javadocs}"
      author="true"
      version="true"
      locale="en"
      windowtitle="${Name} API"
      doctitle="${Name}"
      failonerror="true"
      verbose="${javadoc.verbose}"
      additionalparam="${javadoc.doclint.none}">

      <packageset dir="${java.dir}"/>

      <!-- hide some meta information for javadoc -->
      <tag name="todo" description="To do:" scope="all"/>
      <tag name="ant.task" enabled="false" description="Task:" scope="types"/>
      <tag name="ant.datatype" enabled="false" description="Data type:" scope="types"/>
      <tag name="ant.attribute" enabled="false" description="Attribute:" scope="types"/>
      <tag name="ant.attribute.group" enabled="false" description="Attribute group:" scope="types"/>
      <tag name="ant.element" enabled="false" description="Nested element:" scope="types"/>
      <group title="Apache Ant Core" packages="org.apache.tools.ant*"/>
      <group title="Core Tasks" packages="org.apache.tools.ant.taskdefs*"/>
      <group title="Core Types" packages="org.apache.tools.ant.types*"/>
      <group title="Optional Tasks" packages="org.apache.tools.ant.taskdefs.optional*"/>
      <group title="Optional Types" packages="org.apache.tools.ant.types.optional*"/>
      <group title="Ant Utilities" packages="org.apache.tools.ant.util*"/>
      <classpath refid="tests-classpath"/>
    </javadoc>
  </target>

  <target name="test-javadocs" depends="prepare, javadoc_check"
    unless="tests.javadoc.notrequired"
    description="--> creates the API documentation for test utilities">
    <mkdir dir="${build.tests.javadocs}"/>
    <javadoc useexternalfile="yes"
      destdir="${build.tests.javadocs}"
      failonerror="true"
      author="true"
      version="true"
      locale="en"
      windowtitle="${Name} Test Utilities"
      doctitle="${Name}"
      additionalparam="${javadoc.doclint.none}">

      <!-- hide some meta information for javadoc -->
      <tag name="pre" description="Precondition:" scope="all"/>

      <fileset dir="${src.junit}">
        <patternset refid="useful.tests"/>
      </fileset>
      <classpath refid="tests-classpath"/>
    </javadoc>
  </target>

  <!--
       ===================================================================
         Compile testcases
       ===================================================================
  -->
  <target name="compile-tests" depends="build" if="junit.present">
    <mkdir dir="${build.tests}"/>

    <javac srcdir="${src.junit}"
      includeantruntime="false"
      destdir="${build.tests}"
      debug="${debug}"
      target="${javac.target}"
      source="${javac.source}"
      deprecation="${deprecation}">
      <classpath refid="tests-classpath"/>

      <selector refid="conditional-patterns"/>
    </javac>

    <!-- Used by AntlibTest.testAntlibResource: -->
    <jar jarfile="${build.tests}/org/apache/tools/ant/taskdefs/test2-antlib.jar">
      <manifest>
        <attribute name="Extension-name"
          value="org.apache.tools.ant"/>
        <attribute name="Specification-Title"
          value="Apache Ant"/>
        <attribute name="Specification-Version"
          value="${manifest-version}"/>
        <attribute name="Specification-Vendor"
          value="Apache Software Foundation"/>
        <attribute name="Implementation-Title"
          value="org.apache.tools.ant"/>
        <attribute name="Implementation-Version"
          value="${manifest-version}"/>
        <attribute name="Implementation-Vendor"
          value="Apache Software Foundation"/>
      </manifest>
      <zipfileset dir="${tests.etc.dir}" fullpath="taskdefs/test.antlib.xml">
        <include name="taskdefs/test2.antlib.xml"/>
      </zipfileset>
    </jar>
  </target>

  <target name="dump-info" depends="dump-sys-properties,run-which"/>

  <target name="dump-sys-properties" unless="which.present"
    depends="xml-check">
    <echo message="java.vm.info=${java.vm.info}"/>
    <echo message="java.vm.name=${java.vm.name}"/>
    <echo message="java.vm.vendor=${java.vm.vendor}"/>
    <echo message="java.vm.version=${java.vm.version}"/>
    <echo message="os.arch=${os.arch}"/>
    <echo message="os.name=${os.name}"/>
    <echo message="os.version=${os.version}"/>
    <echo message="file.encoding=${file.encoding}"/>
    <echo message="user.language=${user.language}"/>
    <echo message="ant.version=${ant.version}"/>
  </target>

  <!-- helper class from Xalan2 to check for jar versioning of xml/xsl processors -->
  <target name="xml-check" depends="check_for_optional_packages"
    if="xalan.envcheck" unless="which.present">
    <java classname="org.apache.xalan.xslt.EnvironmentCheck"/>
  </target>

  <target name="run-which" depends="check_for_optional_packages"
    if="which.present">
    <java classname="org.apache.env.Which" taskname="which" classpathref="classpath"/>
  </target>

  <!-- test to see if we are online or not. can take a while when we are off line, so
    setting the property is a good shortcut-->
  <target name="probe-offline">
    <condition property="offline">
      <or>
        <isset property="offline"/>
        <not>
          <http url="http://www.apache.org/"/>
        </not>
      </or>
    </condition>
    <echo level="verbose"> offline=${offline}</echo>
  </target>

  <!--
       ===================================================================
         Run testcase
       ===================================================================
  -->

  <target name="check-failed">
    <condition property="tests.failed">
      <or>
        <isset property="junit.failed" />
        <isset property="antunit.failed" />
      </or>
    </condition>
  </target>

  <target name="test" description="--> run unit tests and reports"
          depends="dump-info,junit-report,antunit-report,check-failed">
    <fail if="tests.failed" unless="ignore.tests.failed">Unit tests failed; see:
${build.junit.reports}
${antunit.reports}
    </fail>
  </target>

  <target name="run-tests" depends="dump-info,junit-tests,antunit-tests,check-failed"
          description="--> run unit tests without reports">
    <fail if="tests.failed" message="Unit tests failed" />
  </target>

  <target name="test-init" depends="probe-offline,check_for_optional_packages">
    <mkdir dir="${build.junit.tmpdir}"/>
    <macrodef name="test-junit">
      <element name="junit-nested" implicit="true" />
      <sequential>
        <!-- Delete 'old' collector classes -->
        <delete failonerror="false">
          <fileset dir="${junit.collector.dir}" includes="${junit.collector.class}*.class"/>
        </delete>
        <!-- compile the FailedTests class if present -->
        <mkdir dir="${junit.collector.dir}"/>
        <!-- FIXME: removed junit collector build code
        <javac srcdir="${junit.collector.dir}" destdir="${junit.collector.dir}">
          <classpath id="failure.cp">
            <pathelement location="${build.classes}"/>
            <pathelement location="${build.tests}"/>
          </classpath>
        </javac>
             -->
        <available file="${junit.collector.dir}/${junit.collector.class}.class"
                   property="hasFailingTests"/>
        <!-- run the tests -->
        <mkdir dir="${build.junit.xml}" />
        <property name="test.junit.vmargs" value=""/>
        <property name="ant.junit.failureCollector"
                  value="${junit.collector.dir}/${junit.collector.class}"/>
        <!-- TODO includeantruntime="false" does not solve "multiple versions of ant detected in path for junit" warning -->
        <junit printsummary="${junit.summary}"
               haltonfailure="${test.haltonfailure}"
               fork="${junit.fork}"
               forkmode="${junit.forkmode}"
               threads="${junit.threads}"
               failureproperty="junit.failed"
               errorproperty="junit.failed"
               filtertrace="${junit.filtertrace}">
          <sysproperty key="ant.home" value="${ant.home}"/>
          <sysproperty key="build.tests" file="${build.tests}"/>
          <sysproperty key="build.tests.value" value="${build.tests.value}"/>
          <sysproperty key="offline" value="${offline}"/>
          <sysproperty key="tests-classpath.value"
                       value="${toString:tests-runtime-classpath}"/>
          <sysproperty key="root" file="${basedir}"/>
          <sysproperty key="build.compiler" value="${build.compiler}"/>
          <sysproperty key="tests.and.ant.share.classloader"
                       value="${tests.and.ant.share.classloader}"/>
          <sysproperty key="java.io.tmpdir" file="${build.junit.tmpdir}"/>
          <classpath>
            <path refid="tests-runtime-classpath"/>
            <pathelement location="${junit.collector.dir}"/>
            <!-- FIXME: remove failure collector build code for the moment
                 <path refid="failure.cp"/> 
                 -->
          </classpath>
          <!-- FIXME: remove failure collector build code for the moment
          <formatter type="failure" usefile="false"/>
               -->
          <formatter type="xml"/>
          <jvmarg line="${test.junit.vmargs}"/>
          <!-- FIXME: remove failure collector build code for the moment
          <test name="${junit.collector.class}" if="hasFailingTests"/>
          -->
          <junit-nested />
        </junit>
      </sequential>
    </macrodef>

    <fail>"testcase" cannot be specified with "junit.testcase" or "antunit.testcase".
      <condition>
        <and>
          <isset property="testcase" />
          <or>
            <isset property="antunit.testcase" />
            <isset property="junit.testcase" />
          </or>
        </and>
      </condition>
    </fail>

    <condition property="antunit.testcase" value="${testcase}">
      <available file="${src.antunit}/${testcase}" />
    </condition>

    <condition property="junit.testcase" value="${testcase}">
      <available classname="${testcase}" classpathref="tests-runtime-classpath" ignoresystemclasses="${ignoresystemclasses}"/>
    </condition>

    <fail>Cannot locate test ${testcase}
      <condition>
        <and>
          <isset property="testcase" />
          <not>
            <or>
              <isset property="antunit.testcase" />
              <isset property="junit.testcase" />
            </or>
          </not>
        </and>
      </condition>
    </fail>

    <condition property="run.junit">
      <and>
        <not><equals arg1="${testcase}" arg2="${antunit.testcase}" /></not>
        <isset property="junit.present" />
        <available file="${src.junit}" />
      </and>
    </condition>

    <condition property="junit.single">
      <and>
        <isset property="junit.testcase" />
        <isset property="run.junit" />
      </and>
    </condition>

    <condition property="junit.batch">
      <and>
        <not><isset property="junit.testcase" /></not>
        <isset property="run.junit" />
      </and>
    </condition>

    <condition property="run.antunit">
      <and>
        <not><equals arg1="${testcase}" arg2="${junit.testcase}" /></not>
        <isset property="antunit.present" />
        <available file="${src.antunit}" />
      </and>
    </condition>

    <condition property="run.antunit.report">
      <isset property="run.antunit" />
    </condition>

    <condition property="run.junit.report">
      <isset property="run.junit" />
    </condition>
  </target>

  <target name="junit-report" depends="junit-tests,junit-report-only" />

  <target name="junit-report-only" depends="test-init" if="${run.junit.report}">
    <mkdir dir="${build.junit.reports}" />
    <junitreport todir="${build.junit.reports}">
      <fileset dir="${build.junit.xml}">
        <include name="TEST-*.xml"/>
      </fileset>
      <report format="frames" todir="${build.junit.reports}"/>
    </junitreport>
  </target>

  <target name="junit-tests" depends="junit-batch,junit-single-test" />

  <target name="junit-batch" depends="compile-tests,test-init"
      if="junit.batch">

    <property name="junit.includes" value="**/*Test*" />
    <property name="junit.excludes" value="" />

    <test-junit>
      <formatter type="brief" usefile="false"/>

      <batchtest todir="${build.junit.xml}" unless="hasFailingTests">
        <fileset dir="${src.junit}"
                 includes="${junit.includes}" excludes="${junit.excludes}">

          <!-- abstract classes, not testcases -->
          <exclude name="${taskdefs.package}/TaskdefsTest.java"/>
          <exclude name="${ant.package}/BuildFileTest.java"/>
          <exclude name="${regexp.package}/RegexpMatcherTest.java"/>
          <exclude name="${regexp.package}/RegexpTest.java"/>
          <exclude name="${optional.package}/AbstractXSLTLiaisonTest.java"/>
          <exclude name="${ant.package}/types/AbstractFileSetTest.java"/>
          <exclude name="${ant.package}/types/selectors/BaseSelectorTest.java"/>

          <!-- helper classes, not testcases -->
          <exclude name="org/example/"/>
          <exclude name="${taskdefs.package}/TaskdefTest*Task.java"/>
          <exclude name="${optional.package}/junit/TestFormatter.java"/>

          <!-- interactive tests -->
          <exclude name="${taskdefs.package}/TestProcess.java"/>
          <exclude name="${optional.package}/splash/SplashScreenTest.java"/>

          <!-- only run these tests if their required libraries are
               installed -->
          <selector refid="conditional-patterns"/>

          <!-- tests excluded if the test is run in offline mode -->
          <patternset refid="onlinetests"/>

          <!-- failing tests excluded unless run.failing.tests is set -->
          <patternset refid="teststhatfail"/>

          <!-- needs BSF to work -->
          <exclude name="${optional.package}/Rhino*.java"
            unless="bsf.present"/>
          <exclude name="${optional.package}/Rhino*.java"
            unless="rhino.present"/>
          <exclude name="${optional.package}/script/*.java"
            unless="bsf.present"/>
          <exclude name="${optional.package}/script/*.java"
            unless="rhino.present"/>
          <exclude name="${optional.package}/BeanShellScriptTest.java"
            unless="bsf.present"/>
          <exclude name="${optional.package}/BeanShellScriptTest.java"
            unless="beanshell.present"/>
          <exclude name="${optional.type.package}/Script*.java"
            unless="bsf.present"/>
          <exclude name="${optional.type.package}/Script*.java"
            unless="rhino.present"/>

          <!-- fail if testcases can be loaded from the system classloader -->
          <exclude name="${ant.package}/AntClassLoaderDelegationTest.java"
            if="tests.are.on.system.classpath"/>
          <exclude name="${optional.package}/junit/JUnitClassLoaderTest.java"
            if="tests.are.on.system.classpath"/>

          <!-- these tests need to be localised before being ran???? -->
          <exclude name="${optional.package}/PvcsTest.java"/>

          <exclude name="${optional.package}/junit/JUnitReportTest.java"
            unless="run.junitreport"/>

          <!-- needs xerces to work -->
          <exclude name="${ant.package}/IncludeTest.java"
            unless="xerces1.present"/>
          <exclude name="${type.package}/selectors/ModifiedSelectorTest.java"
            unless="xerces1.present"/>

          <!-- needs resolver.jar to work -->
          <exclude name="${optional.package}/XmlValidateCatalogTest.java"
            unless="apache.resolver.present"/>

          <!-- needs jasperc -->
          <exclude name="${optional.package}/JspcTest.java"
            unless="jasper.present"/>

          <!--  These tests only passes if testcases and Ant classes have
          been loaded by the same classloader - will throw
          IllegalAccessExceptions otherwise.  -->
          <exclude name="${taskdefs.package}/SQLExecTest.java"
            unless="tests.and.ant.share.classloader"/>
          <exclude name="${taskdefs.package}/cvslib/ChangeLogWriterTest.java"
            unless="tests.and.ant.share.classloader"/>
          <exclude name="${taskdefs.package}/cvslib/ChangeLogParserTest.java"
            unless="tests.and.ant.share.classloader"/>
          <exclude name="${optional.package}/sos/SOSTest.java"
            unless="tests.and.ant.share.classloader"/>
          <exclude name="${optional.package}/vss/MSVSSTest.java"
            unless="tests.and.ant.share.classloader"/>
          <exclude name="${optional.package}/TraXLiaisonTest.java"
            unless="tests.and.ant.share.classloader"/>
          <exclude name="${taskdefs.package}/ProcessDestroyerTest.java"
            unless="tests.and.ant.share.classloader"/>
          <exclude name="${taskdefs.package}/ProtectedJarMethodsTest.java"
            unless="tests.and.ant.share.classloader"/>
          <exclude name="${ant.package}/launch/LocatorTest.java"
            unless="tests.and.ant.share.classloader"/>
          <exclude name="${ant.package}/DefaultLoggerTest.java"
            unless="tests.and.ant.share.classloader"/>
          <exclude name="${taskdefs.package}/ZipExtraFieldTest.java"
            unless="tests.and.ant.share.classloader"/>

          <!-- can only run if cvs is installed on your machine
               enable by setting the property have.cvs
          -->
          <exclude name="${taskdefs.package}/AbstractCvsTaskTest.java"
            unless="have.cvs"/>

          <!-- needs a local ftp server and the entry of a user/password combination -->
          <exclude name="${optional.package}/net/FTPTest.java"/>

          <!-- test needs special setup -->
          <exclude name="${optional.package}/ssh/ScpTest.java"/>

          <!-- test fails if build/classes and ant.jar are using the same
               classloader  -->
          <exclude name="${ant.package}/util/ClasspathUtilsTest.java"
            if="tests.and.ant.share.classloader"/>
        </fileset>
      </batchtest>
    </test-junit>
  </target>

  <target name="junit-single-test" depends="compile-tests,junit-single-test-only"
    description="--> runs the single unit test at $${junit.testcase}" />

  <target name="junit-single-test-only" depends="test-init" if="junit.single"
    description="--> runs the single unit test at $${junit.testcase} (no compile)">
    <test-junit>
      <formatter type="plain" usefile="false"/>
      <test name="${junit.testcase}" todir="${build.junit.xml}"/>
    </test-junit>
  </target>

  <target name="interactive-tests" description="--> runs interactive tests"
    depends="compile-tests"
    >
    <java classpathref="tests-runtime-classpath"
      classname="org.apache.tools.ant.taskdefs.TestProcess"
      fork="true"/>
  </target>

  <target name="-antunit-check-location">
    <condition property="antunit.recommended.location">
      <or>
        <equals arg1="${ant.home}" arg2="${bootstrap.dir}"/>
        <equals arg1="${ant.home}" arg2="${dist.dir}"/>
      </or>
    </condition>
  </target>
  <target name="-antunit-warn-location" depends="-antunit-check-location" if="run.antunit" unless="${antunit.recommended.location}">
      <echo>AntUnit tests must be run with ${bootstrap.dir} (or ${dist.dir}), not ${ant.home}. Try './build.sh antunit-tests' for example.</echo>
  </target>
  <target name="antunit-tests" depends="dump-info,build,test-init,-antunit-warn-location"
          if="run.antunit" description="--> run the antunit tests">
    <condition property="antunit.includes" value="${antunit.testcase}"
               else="**/test.xml,**/*-test.xml">
      <isset property="antunit.testcase" />
    </condition>

    <property name="antunit.excludes" value="" />

    <mkdir dir="${antunit.xml}" />
    <au:antunit xmlns:au="antlib:org.apache.ant.antunit"
                failonerror="false" errorproperty="antunit.failed">
      <fileset dir="${src.antunit}" includes="${antunit.includes}"
               excludes="${antunit.excludes}" />
      <au:plainlistener logLevel="${antunit.loglevel}"/>
      <au:xmllistener todir="${antunit.xml}" />
      <propertyset>
        <propertyref name="antunit.tmpdir"/>
        <propertyref name="ant.home"/>
      </propertyset>
    </au:antunit>
  </target>

  <target name="antunit-report" depends="antunit-tests,antunit-report-only" />

  <target name="antunit-report-only" depends="test-init" if="run.antunit.report">
    <length>
      <fileset dir="${antunit.xml}" includes="TEST-*.xml" />
    </length>
    <mkdir dir="${antunit.reports}" />
    <junitreport todir="${antunit.reports}">
      <fileset dir="${antunit.xml}" includes="TEST-*.xml" />
      <report styledir="${src.antunit}" format="frames"
              todir="${antunit.reports}"/>
    </junitreport>
    <length>
      <fileset dir="${antunit.xml}" includes="TEST-*.xml" />
    </length>
  </target>
  
  
  <target name="printFailingTests">
    <property name="failingtests.dir" value="${build.dir}/errors"/>
    <mkdir dir=""/>
    <xslt 
      style="${etc.dir}/printFailingTests.xsl" 
      destdir="${failingtests.dir}" extension=".txt"
      basedir="${build.dir}" includes="testcases/**/TEST-*.xml,antunit/xml/TEST-*.xml"
    />
    <echo>+-------------------------------------------------------------------------------------</echo>
    <echo>| FAILING TESTS:</echo>
    <echo>+-------------------------------------------------------------------------------------</echo>
    <concat>
      <!-- generated message files if they arent empty -->
      <fileset dir="${failingtests.dir}">
        <size value="0" when="more"/>
      </fileset>
      <!-- 'skip' empty lines -->
      <filterchain>
        <linecontains>
          <contains value="|"/>
        </linecontains>
      </filterchain>
    </concat>
    <echo>+-------------------------------------------------------------------------------------</echo>
  </target>

  <!--
       ===================================================================
         Main target - runs dist-lite by default
       ===================================================================
  -->
  <target name="main"
    description="--> creates a minimum distribution in ./dist"
    depends="dist-lite"/>


  <!--
       ===================================================================
         MSI target - creates an MSI installer file with the help of
                      the WiX toolset and the dotnet Antlib.
       ===================================================================
  -->
  <target name="msi"
    description="--> creates an MSI file for Ant, requires WiX and the dotnet Antlib"
    depends="internal_dist"
    xmlns:dn="antlib:org.apache.ant.dotnet">

    <property name="msi.dir" value="${build.dir}"/>
    <property name="msi.name" value="${name}-${project.version}.msi"/>
    <property name="msi.file" value="${msi.dir}/${msi.name}"/>
    <property name="wix.home" value="${user.home}/wix"/>
    <property name="wixobj.dir" value="${build.dir}/wix"/>

    <property name="dist.dir.resolved" location="${dist.dir}"/>

    <mkdir dir="${wixobj.dir}"/>

    <dn:wix target="${msi.file}"
      mode="both" wixHome="${wix.home}" wixobjDestDir="${wixobj.dir}">
      <sources dir="${etc.dir}" includes="*.wxs"/>
      <moresources dir="${dist.dir}"/>

      <candleParameter name="dist.dir" value="${dist.dir.resolved}"/>
      <candleParameter name="version" value="${manifest-version}"/>
    </dn:wix>
  </target>

</project>
