<?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="JMeter" default="install" basedir="."
    xmlns:rat="antlib:org.apache.rat.anttasks"
    xmlns:jacoco="antlib:org.jacoco.ant"
    xmlns="antlib:org.apache.tools.ant"
    xmlns:if="ant:if" >
  <description>

  N.B. To build JMeter from a release you need both the binary and source archives,
  and these must be unpacked into the same directory structure.

  To download additional jars needed for building the code and documentation:

      ant download_jars


    To build JMeter from source:
      ant [install]

    To rebuild:
      ant clean install

    To update documentation
      ant docs-site [-Ddocs.force=true]
      ant docs-printable [-Ddocs.force=true]
    To build API documentation (Javadoc)
      ant docs-api
    To build all the docs
      ant docs-all [-Ddocs.force=true]

    To build all and package up the files for distribution
      ant distribution -Djmeter.version=vvvv [-Dsvn.revision=nnnnn]

    Add -Ddisable-svnCheck=true to disable svn check, if you build from src archive or offline
    Add -Ddisable-check-versions=true to disable matching current svn revision and JMeterVersion.java,
      if you want build your own custom JMeter package.

    To create a nightly build (separate bin/src/lib jars):
      ant nightly [-Dsvn.revision=nnnnn]

    To create tar and tgz of the web-site documentation (docs and api)
      ant site [ -Djmeter.version=vvvv ]


    For more info:
      ant -projecthelp

    To diagnose usage of deprecated APIs:
      ant -Ddeprecation=on clean compile
  </description>

  <!--

  Note
  ====
  As with most other Apache projects, Gump (http://gump.apache.org/) is used to
  perform automated builds and tests on JMeter.

  Gump uses its project/jmeter.xml file to determine which target to use.
  The current setting is: <ant target="dist">

  Any changes to the dependency list for dist may affect Gump.

  Now the dist target depends on "assume-libs-present", so if additional libraries are added to that,
  the Gump project file for JMeter must also be updated.

  Jars that are not required by the dist target do not need to be added to the Gump project file.

  -->

  <!-- Minimal version of Apache Ant required by this Ant script -->
  <property name="ant.version.required" value="1.9.1" />

  <!-- check if JavaFX is available -->
  <available classname="javafx.application.Platform" property="javafx.present" />

  <!-- Are we running under Gump? -->
  <property name="gump.run" value="false"/>

  <!-- The version of this file -->
  <property name="version.build" value="$Revision: 1855137 $"/>

  <script language="javascript">
    project.setProperty('EPOCHSECONDS', new Date().getTime());
  </script>

  <property file="build-local.properties"/> <!-- allow local overrides -->

  <!-- Remove .gitignore from the Ant's default excludes -->
  <!-- to allow to have the .gitignore in the source archive -->
  <defaultexcludes remove="**/.gitignore"/>

   <!-- Findbugs task and target -->
   <!--
   Findbugs is licensed under the Lesser GNU Public License
   HomePage: http://www.cs.umd.edu/~pugh/java/bugs/

   To use the findbugs target, download and install the findbugs binary distribution
   Set the value of findbugs.homedir according to where you installed findbugs, for example:
   ant findbugs -Dfindbugs.homedir=/etc/findbugs -Dfindbugs.level=medium
  [The defaults are /findbugs and medium]
   -->
  <property name="findbugs.homedir" value="/findbugs" />
  <property name="findbugs.level" value="medium" />
  <property name="findbugs.xsldir" value="${findbugs.homedir}/src/xsl" />
  <property name="findbugs.xslname" value="fancy" />
  <property name="findbugs.outName" value="reports/jmeter-fb" />
  <property name="skip.batchtest" value="false" />
  <property name="skip.bug52310" value="false" />
  <property name="skip.bug60607" value="false" />
  <property name="skip.batchtest_Http4ImplPreemptiveBasicAuth" value="false" />
  <property name="skip.batchtest_SlowCharsFeature" value="false" />
  <property name="skip.batchtest_TestKeepAlive" value="false" />
  <property name="skip.batchtest_ResponseDecompression" value="false" />
  <property name="skip.test_https" value="false" />
  <property name="skip.test_http" value="false" />
  <property name="skip.test_TestDNSCacheManager.testWithCustomResolverAnd1Server" value="false" />

  <exec executable="hostname" outputproperty="computer.hostname"/>

  <target name="findbugs" description="Run the stand-alone Findbugs detector">
    <echoproperties prefix="findbugs"/>
    <mkdir dir="reports"/>
    <taskdef name="findbugs"
        classpath="${findbugs.homedir}/lib/findbugs-ant.jar"
        classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/>
    <findbugs home="${findbugs.homedir}"
              output="xml:withMessages"
              reportlevel="${findbugs.level}"
              excludeFilter="fb-excludes.xml"
              jvmargs="-Xms512m -Xmx1024m"
              omitVisitors="InefficientStringBuffering"
              outputFile="${findbugs.outName}.xml" >
      <sourcePath path="${src.core}" />
      <sourcePath path="${src.http}" />
      <sourcePath path="${src.ftp}" />
      <sourcePath path="${src.java}" />
      <sourcePath path="${src.junit}" />
      <sourcePath path="${src.jdbc}" />
      <sourcePath path="${src.ldap}" />
      <sourcePath path="${src.mail}" />
      <sourcePath path="${src.components}" />
      <sourcePath path="${src.functions}" />
      <class location="${lib.dir}/jorphan.jar" />
      <class location="${dest.jar}/ApacheJMeter_components.jar"/>
      <class location="${dest.jar}/ApacheJMeter_components.jar"/>
      <class location="${dest.jar}/ApacheJMeter_core.jar"/>
      <class location="${dest.jar}/ApacheJMeter_ftp.jar"/>
      <class location="${dest.jar}/ApacheJMeter_functions.jar"/>
      <class location="${dest.jar}/ApacheJMeter_http.jar"/>
      <class location="${dest.jar}/ApacheJMeter_java.jar"/>
      <class location="${dest.jar}/ApacheJMeter_jdbc.jar"/>
      <class location="${dest.jar}/ApacheJMeter_jms.jar"/>
      <class location="${dest.jar}/ApacheJMeter_junit.jar"/>
      <class location="${dest.jar}/ApacheJMeter_ldap.jar"/>
      <class location="${dest.jar}/ApacheJMeter_mail.jar"/>
      <class location="${dest.jar}/ApacheJMeter_native.jar"/>
      <class location="${dest.jar}/ApacheJMeter_mongodb.jar"/>
      <class location="${dest.jar}/ApacheJMeter_tcp.jar"/>
      <class location="${dest.jar.jmeter}/ApacheJMeter.jar" />
      <sourcePath path="${src.jorphan}" />
      <sourcePath path="${src.tcp}" />
      <sourcePath path="${src.jms}" />
      <sourcePath path="${src.native}" />
      <sourcePath path="${src.mongodb}" />

      <auxClasspath>
        <fileset dir="${lib.dir}">
          <include name="*.jar"/>
        </fileset>
      </auxClasspath>

      <auxClasspath>
        <fileset dir="${lib.opt}">
          <include name="*.jar"/>
        </fileset>
      </auxClasspath>

      <auxClasspath>
        <fileset dir="${lib.api}">
          <include name="*.jar"/>
        </fileset>
      </auxClasspath>

    </findbugs>
    <antcall target="findbugs-style"/>
    <antcall target="findbugs-xsl"/>
  </target>

  <!-- Convert findbugs XML output to CSV -->
  <target name="findbugs-style">
    <xslt style="fb-csv.xsl"
       force="true"
       in="${findbugs.outName}.xml"
       out="${findbugs.outName}.csv">
    </xslt>
  </target>

  <!-- Convert findbugs XML output to HTML -->
  <target name="findbugs-xsl">
    <xslt style="${findbugs.xsldir}/${findbugs.xslname}.xsl"
       force="true"
       in="${findbugs.outName}.xml"
       out="${findbugs.outName}_${findbugs.xslname}.html">
    </xslt>
  </target>

  <!-- Where the Sources live -->
  <property name="src.dir" value="src"/>
  <property name="src.core" value="src/core"/>
  <property name="src.http" value="src/protocol/http"/>
  <property name="src.ftp" value="src/protocol/ftp"/>
  <property name="src.test" value="test/src"/>
  <property name="src.jdbc" value="src/protocol/jdbc"/>
  <property name="src.java" value="src/protocol/java"/>
  <property name="src.junit" value="src/junit"/>
  <property name="src.components" value="src/components"/>
  <property name="src.functions" value="src/functions"/>
  <property name="src.jorphan" value="src/jorphan"/>
  <property name="src.ldap" value="src/protocol/ldap"/>
  <property name="src.tcp" value="src/protocol/tcp"/>
  <property name="src.examples" value="src/examples"/>
  <property name="src.mail" value="src/protocol/mail"/>
  <property name="src.jms" value="src/protocol/jms"/>
  <property name="src.native" value="src/protocol/native"/>
  <property name="src.mongodb" value="src/protocol/mongodb"/>

  <!-- Where the documentation sources live -->
  <property name="src.docs" value="xdocs"/>
  <property name="src.css" value="xdocs/css"/>
  <property name="src.images" value="xdocs/images"/>
  <property name="src.demos" value="xdocs/demos"/>

  <!-- Javadoc sources -->
  <path id="srcpaths">
    <pathelement location="${src.core}"/>
    <pathelement location="${src.components}"/>
    <pathelement location="${src.functions}"/>
    <pathelement location="${src.http}"/>
    <pathelement location="${src.ftp}"/>
    <pathelement location="${src.jdbc}"/>
    <pathelement location="${src.java}"/>
    <pathelement location="${src.junit}"/>
    <pathelement location="${src.jorphan}"/>
    <pathelement location="${src.ldap}"/>
    <pathelement location="${src.tcp}"/>
    <pathelement location="${src.examples}"/>
    <pathelement location="${src.mail}"/>
    <pathelement location="${src.jms}"/>
    <pathelement location="${src.native}"/>
    <pathelement location="${src.mongodb}"/>
  </path>

  <!-- Temporary build directories: where the .class live -->
  <property name="build.dir" value="build"/>
  <property name="build.core" value="build/core"/>
  <property name="build.http" value="build/protocol/http"/>
  <property name="build.ftp" value="build/protocol/ftp"/>
  <property name="build.jdbc" value="build/protocol/jdbc"/>
  <property name="build.java" value="build/protocol/java"/>
  <property name="build.junit" value="build/junit"/>
  <property name="build.components" value="build/components"/>
  <property name="build.functions" value="build/functions"/>
  <property name="build.jorphan" value="build/jorphan"/>
  <property name="build.ldap" value="build/protocol/ldap"/>
  <property name="build.mail" value="build/protocol/mail"/>
  <property name="build.tcp" value="build/protocol/tcp"/>
  <property name="build.examples" value="build/examples"/>
  <property name="build.jms" value="build/protocol/jms"/>
  <property name="build.native" value="build/protocol/native"/>
  <property name="build.mongodb" value="build/protocol/mongodb"/>
  <property name="build.test" value="build/test"/>
  <property name="build.res" value="build/res"/>
  <property name="build.test-res" value="test/resources"/>

  <!-- Path prefix to allow Anakia to find stylesheets if running under Eclipse -->
  <!--
  Anakia looks for stylesheets relative to the java launch directory.
  Use the External Tools properties page to define the variable
  as the relative path to the directory where this build file is found.
  For example:
               eclipse.anakia=workspace/jmeter

  An alternative is to define it as a command-line argument on the Main page;
  this allows one to use a macro name, so is more portable.
  For example:
               -Declipse.anakia=workspace/${project_name}
  WARNING: you must ensure that you have selected a file or directory in
  the Navigator pane before attempting to run the build, or Eclipse will
  complain that it cannot resolve the variable name, and it can mark the
  launch configuration as having failed.
  -->
  <property name="eclipse.anakia" value="."/>

  <!-- Where the build result .jars will be placed -->
  <property name="dest.jar" value="lib/ext"/>
  <property name="dest.jar.jmeter" value="bin"/>

  <!-- Where the API documentation lives -->
  <property name="dest.docs.api" value="docs/api"/>

  <!-- Where the doc results live -->
  <property name="dest.docs" value="docs"/>
  <property name="dest.printable_docs" value="printable_docs"/>

  <!-- Whether to force docs to be rebuilt -->
  <property name="docs.force" value="false"/>

  <!-- Default is for Anakia to only rebuild if the target file is older than the source -->
  <condition property="anakia.lastModifiedCheck" value="true" else="false">
    <!-- docs.force uses the opposite sense to the anakia check -->
    <isfalse value="${docs.force}"/>
  </condition>
  <condition property="java9">
      <equals arg1="${ant.java.version}" arg2="9"/>
  </condition>

  <!-- Directory where jars needed for creating documentation live -->
  <property name="lib.doc" value="lib/doc"/>

  <!-- Directory where these 3rd party libraries live -->
  <property name="lib.dir" value="lib"/>

  <!-- Directory where API spec libraries live -->
  <property name="lib.api" value="lib/api"/>

  <!-- Directory where Optional 3rd party libraries live -->
  <property name="lib.opt" value="lib/opt"/>

  <!-- Directory where Jacoco libraries live -->
  <!-- I'm to lazy to fix this now, so I tag along with rat & checkstyle,
    which already live there. But: none of these should appear on the classpath
    of JMeter, neither runtime, nor compiletime. These are only required on the
    Ant classpath, so judging from comments elsewhere, this is the wrong place.
  -->
  <property name="lib.coverage" location="lib/opt"/>

  <!-- Other stuff -->
  <property name="extras.dir" value="extras"/>

  <!-- Some resources to add to jars -->
  <property name="res.dir" value="res"/>

  <!-- Where the distribution packages will be created -->
  <property name="dist.dir" value="dist"/>

  <!-- Where the Maven artifacts will be created -->
  <property name="maven.dir" value="${dist.dir}/maven"/>

  <!-- Where the Maven template poms are located -->
  <property name="maven.poms" value="res/maven"/>

  <!-- Compilation parameters -->
  <property name="optimize" value="on"/>
  <property name="deprecation" value="off"/>
  <property name="target.java.version" value="1.8"/>
  <property name="src.java.version" value="1.8"/>
  <property name="encoding" value="UTF-8"/>
  <!-- Set test encoding to the same default, but allow override -->
  <property name="test.encoding" value="${encoding}"/>
  <!-- Set javadoc encoding to the same default, but allow override -->
  <property name="javadoc.encoding" value="${encoding}"/>
  <property name="includeAntRuntime" value="false"/>

  <!-- 3rd party libraries to be included in the binary distribution -->
  <property file="build.properties"/> <!-- defines the library version numbers -->

  <property name="resources.meta-inf"      value="${build.res}/META-INF"/>

  <patternset id="external.jars.notices">
    <include name="LICENSE"/>
    <include name="NOTICE"/>
    <include name="README.md"/>
  </patternset>

  <!-- Jars for binary release -->
  <patternset id="external.jars">
    <include name="${lib.dir}/${accessors-smart.jar}"/>
    <include name="${lib.dir}/${apache-bsf.jar}"/>
    <include name="${lib.dir}/${asm.jar}"/>
    <include name="${lib.dir}/${beanshell.jar}"/>
    <include name="${lib.dir}/${dec.jar}"/>
    <include name="${lib.dir}/${caffeine.jar}"/>
    <include name="${lib.dir}/${commons-codec.jar}"/>
    <include name="${lib.dir}/${commons-collections.jar}"/>
    <include name="${lib.dir}/${commons-dbcp2.jar}"/>
    <include name="${lib.dir}/${commons-io.jar}"/>
    <include name="${lib.dir}/${commons-jexl2.jar}"/>
    <include name="${lib.dir}/${commons-jexl3.jar}"/>
    <include name="${lib.dir}/${commons-lang3.jar}"/>
    <include name="${lib.dir}/${commons-math3.jar}"/>
    <include name="${lib.dir}/${commons-net.jar}"/>
    <include name="${lib.dir}/${commons-pool2.jar}"/>
    <include name="${lib.dir}/${commons-text.jar}"/>
    <include name="${lib.dir}/${darcula.jar}"/>
    <include name="${lib.dir}/${dnsjava.jar}"/>
    <include name="${lib.dir}/${freemarker.jar}"/>
    <include name="${lib.dir}/${groovy-all.jar}"/>
    <include name="${lib.dir}/${hamcrest-core.jar}"/>
    <include name="${lib.dir}/${hamcrest-date.jar}"/>
    <include name="${lib.dir}/${httpclient.jar}"/>
    <include name="${lib.dir}/${httpasyncclient.jar}"/>
    <include name="${lib.dir}/${httpcore.jar}"/>
    <include name="${lib.dir}/${httpcore-nio.jar}"/>
    <include name="${lib.dir}/${httpmime.jar}"/>
    <include name="${lib.dir}/${jakarta-oro.jar}"/>
    <include name="${lib.dir}/${jackson-annotations.jar}"/>
    <include name="${lib.dir}/${jackson-core.jar}"/>
    <include name="${lib.dir}/${jackson-databind.jar}"/>
    <include name="${lib.dir}/${javamail.jar}"/>
    <include name="${lib.dir}/${jcharts.jar}"/>
    <include name="${lib.dir}/${jcl-over-slf4j.jar}"/>
    <include name="${lib.dir}/${jms.jar}"/>
    <include name="${lib.dir}/${rhino.jar}"/>
    <include name="${lib.dir}/${javax.activation.jar}"/>
    <include name="${lib.dir}/${javax.activation-api.jar}"/>
    <include name="${lib.dir}/${jodd-core.jar}"/>
    <include name="${lib.dir}/${jodd-lagarto.jar}"/>
    <include name="${lib.dir}/${jodd-log.jar}"/>
    <include name="${lib.dir}/${jodd-props.jar}"/>
    <include name="${lib.dir}/${json-path.jar}"/>
    <include name="${lib.dir}/${json-smart.jar}"/>
    <include name="${lib.dir}/${jsoup.jar}"/>
    <include name="${lib.dir}/${junit.jar}"/>
    <include name="${lib.dir}/${log4j-1.2-api.jar}"/>
    <include name="${lib.dir}/${log4j-core.jar}"/>
    <include name="${lib.dir}/${log4j-slf4j-impl.jar}"/>
    <include name="${lib.dir}/${mongo-java-driver.jar}"/>
    <include name="${lib.dir}/${ph-css.jar}"/>
    <include name="${lib.dir}/${ph-commons.jar}"/>
    <include name="${lib.dir}/${rsyntaxtextarea.jar}"/>
    <include name="${lib.dir}/${serializer.jar}"/>
    <include name="${lib.dir}/${slf4j-api.jar}"/>
    <include name="${lib.dir}/${log4j-api.jar}"/>
    <include name="${lib.dir}/${jtidy.jar}"/>
    <include name="${lib.dir}/${tika-core.jar}"/>
    <include name="${lib.dir}/${tika-parsers.jar}"/>
    <include name="${lib.dir}/${xalan.jar}"/>
    <include name="${lib.dir}/${Saxon-HE.jar}"/>
    <include name="${lib.dir}/${xerces.jar}"/>
    <include name="${lib.dir}/${xml-apis.jar}"/>
    <include name="${lib.dir}/${xmlgraphics-commons.jar}"/>
    <include name="${lib.dir}/${xmlpull.jar}"/>
    <include name="${lib.dir}/${xpp3.jar}"/>
    <include name="${lib.dir}/${xstream.jar}"/>
  </patternset>

  <!--
  Optional jars, not included in distribution.
  Any such jars need to be downloaded separately.
  These can be put into ${lib.dir} or ${lib.opt}
  - both of these are included in the build classpath

  Any jars put into ${lib.dir} will be included in
  the classpath used by JMeter to load classes.
  Jars in ${lib.opt} are NOT normally included by JMeter.

  Placing an optional jar in ${lib.opt} means that it
  will be included in the build classpath, but it will
  not be included in the runtime classpath. This is intended
  for testing JMeter without the optional Jar file(s).
  -->

  <!-- Build classpath (includes the optional jar directory) -->
  <path id="classpath">
    <!-- Externally produced jars -->
    <pathelement location="${lib.dir}/${accessors-smart.jar}"/>
    <pathelement location="${lib.dir}/${apache-bsf.jar}"/>
    <pathelement location="${lib.dir}/${asm.jar}"/>
    <pathelement location="${lib.dir}/${beanshell.jar}"/>
    <pathelement location="${lib.dir}/${dec.jar}"/>
    <pathelement location="${lib.dir}/${caffeine.jar}"/>
    <pathelement location="${lib.dir}/${commons-codec.jar}"/>
    <pathelement location="${lib.dir}/${commons-collections.jar}"/>
    <pathelement location="${lib.dir}/${commons-dbcp2.jar}"/>
    <pathelement location="${lib.dir}/${commons-io.jar}"/>
    <pathelement location="${lib.dir}/${commons-jexl2.jar}"/>
    <pathelement location="${lib.dir}/${commons-jexl3.jar}"/>
    <pathelement location="${lib.dir}/${commons-lang3.jar}"/>
    <pathelement location="${lib.dir}/${commons-math3.jar}"/>
    <pathelement location="${lib.dir}/${commons-net.jar}"/>
    <pathelement location="${lib.dir}/${commons-pool2.jar}"/>
    <pathelement location="${lib.dir}/${commons-text.jar}"/>
    <pathelement location="${lib.dir}/${darcula.jar}"/>
    <pathelement location="${lib.dir}/${dnsjava.jar}"/>
    <pathelement location="${lib.dir}/${freemarker.jar}"/>
    <pathelement location="${lib.dir}/${groovy-all.jar}"/>
    <pathelement location="${lib.dir}/${hamcrest-core.jar}"/>
    <pathelement location="${lib.dir}/${hamcrest-date.jar}"/>
    <pathelement location="${lib.dir}/${httpclient.jar}"/>
    <pathelement location="${lib.dir}/${httpasyncclient.jar}"/>
    <pathelement location="${lib.dir}/${httpcore.jar}"/>
    <pathelement location="${lib.dir}/${httpcore-nio.jar}"/>
    <pathelement location="${lib.dir}/${httpmime.jar}"/>
    <pathelement location="${lib.dir}/${jakarta-oro.jar}"/>
    <pathelement location="${lib.dir}/${jackson-annotations.jar}"/>
    <pathelement location="${lib.dir}/${jackson-core.jar}"/>
    <pathelement location="${lib.dir}/${jackson-databind.jar}"/>
    <pathelement location="${lib.dir}/${javamail.jar}"/>
    <pathelement location="${lib.dir}/${jcharts.jar}"/>
    <pathelement location="${lib.dir}/${jms.jar}"/>
    <pathelement location="${lib.dir}/${rhino.jar}"/>
    <pathelement location="${lib.dir}/${javax.activation.jar}"/>
    <pathelement location="${lib.dir}/${javax.activation-api.jar}"/>
    <pathelement location="${lib.dir}/${jodd-core.jar}"/>
    <pathelement location="${lib.dir}/${jodd-lagarto.jar}"/>
    <pathelement location="${lib.dir}/${jodd-log.jar}"/>
    <pathelement location="${lib.dir}/${jodd-props.jar}"/>
    <pathelement location="${lib.dir}/${json-path.jar}"/>
    <pathelement location="${lib.dir}/${json-smart.jar}"/>
    <pathelement location="${lib.dir}/${jsoup.jar}"/>
    <pathelement location="${lib.dir}/${junit.jar}"/>
    <pathelement location="${lib.dir}/${log4j-1.2-api.jar}"/>
    <pathelement location="${lib.dir}/${log4j-core.jar}"/>
    <pathelement location="${lib.dir}/${log4j-slf4j-impl.jar}"/>
    <pathelement location="${lib.dir}/${mongo-java-driver.jar}"/>
    <pathelement location="${lib.dir}/${ph-css.jar}"/>
    <pathelement location="${lib.dir}/${ph-commons.jar}"/>
    <pathelement location="${lib.dir}/${rsyntaxtextarea.jar}"/>
    <pathelement location="${lib.dir}/${serializer.jar}"/>
    <pathelement location="${lib.dir}/${slf4j-api.jar}"/>
    <pathelement location="${lib.dir}/${spock-core.jar}"/>
    <pathelement location="${lib.dir}/${cglib-nodep.jar}"/>
    <pathelement location="${lib.dir}/${objenesis.jar}"/>
    <pathelement location="${lib.dir}/${jtidy.jar}"/>
    <pathelement location="${lib.dir}/${tika-core.jar}"/>
    <pathelement location="${lib.dir}/${tika-parsers.jar}"/>
    <pathelement location="${lib.dir}/${xalan.jar}"/>
    <pathelement location="${lib.dir}/${Saxon-HE.jar}"/>
    <pathelement location="${lib.dir}/${xerces.jar}"/>
    <pathelement location="${lib.dir}/${xml-apis.jar}"/>
    <pathelement location="${lib.dir}/${xmlgraphics-commons.jar}"/>
    <pathelement location="${lib.dir}/${xmlpull.jar}"/>
    <pathelement location="${lib.dir}/${xpp3.jar}"/>
    <pathelement location="${lib.dir}/${xstream.jar}"/>
    <!-- Generated jars -->
    <fileset dir="${lib.dir}" includes="jorphan.jar"/>
    <!-- bshclient is needed to prevent occasional test failures in TestClassFinder -->
    <fileset dir="${lib.dir}" includes="bshclient.jar"/>
    <!-- API-only jars-->
    <fileset dir="${lib.api}" includes="*.jar"/>
    <!-- Optional jars -->
    <fileset dir="${lib.opt}" includes="*.jar"/>
  </path>

  <!-- Logging classpath -->
  <path id="logging.classpath">
    <pathelement location="${lib.dir}/${jcl-over-slf4j.jar}"/>
    <pathelement location="${lib.dir}/${log4j-api.jar}"/>
    <pathelement location="${lib.dir}/${log4j-core.jar}"/>
    <pathelement location="${lib.dir}/${log4j-1.2-api.jar}"/>
    <pathelement location="${lib.dir}/${log4j-slf4j-impl.jar}"/>
  </path>

  <!-- Anakia classpath -->
  <path id="anakia.classpath">
    <pathelement location="${lib.doc}/${velocity.jar}"/>
    <pathelement location="${lib.doc}/${jdom.jar}"/>
    <pathelement location="${lib.dir}/${commons-collections.jar}"/>
    <pathelement location="${lib.doc}/${commons-lang.jar}"/>
  </path>

  <!-- Version info filter set -->
  <tstamp>
    <format property="year" pattern="yyyy" locale="en"/>
  </tstamp>

  <filterset id="year.filters">
    <filter token="YEAR" value="${year}"/>
  </filterset>


  <target name="init-version">
    <tstamp/>
    <!--
      JMeter version
      This is overridden for formal releases.
    -->
    <property name="jmeter.version" value="5.1.1"/>
    <!-- Remember to change "docversion" below if necessary -->
    <condition property="implementation.version"
          value="${jmeter.version} r${svn.revision}" else="${jmeter.version}.${DSTAMP}">
      <isset property="svn.revision"/>
    </condition>
    <property name="display.version" value="${implementation.version}"/>
    <echo level="info">jmeter.version = ${jmeter.version}</echo>
    <echo level="info">display.version = ${display.version}</echo>
    <echo level="info">implementation.version = ${implementation.version}</echo>
    <filterset id="version.filters">
      <filter token="VERSION" value="${display.version}"/>
    </filterset>
  </target>

  <!-- Get version from SVN status -->
  <target name="init-svnVersion" depends="svnCheck">
    <fail message="Could not get SVN revision" unless="svn.revision"/>
    <property name="jmeter.version" value="r${svn.revision}"/>
    <!-- Copy the value to avoid duplication of revision in Manifests -->
    <property name="implementation.version" value="${jmeter.version}"/>
    <property name="display.version" value="${jmeter.version}"/>
    <echo level="info">svn.revision = ${svn.revision}</echo>
    <echo level="info">jmeter.version = ${jmeter.version}</echo>
    <echo level="info">display.version = ${display.version}</echo>
    <echo level="info">implementation.version = ${implementation.version}</echo>
  </target>

  <target name="ant-version" depends="_check_ant-version">
    <echo level="info">ant.version = ${ant.version}</echo>
    <echo level="info">java.version = ${ant.java.version}</echo>
  </target>

  <target name="_check_ant-version">
    <antversion property="version.running" />
    <fail message="FATAL ERROR:  The running Ant version, ${version.running}, is too old for this task.">
      <condition>
        <not>
          <antversion atleast="${ant.version.required}" />
        </not>
      </condition>
    </fail>
  </target>

  <target name="init-docs" depends="report-anakia-missing">
    <echo level="info">eclipse.anakia = ${eclipse.anakia}</echo>
  </target>

  <!--
    - Check for anakia task
  -->
  <target name="check-anakia">
    <available classpathref="anakia.classpath" classname="org.apache.velocity.anakia.AnakiaTask" property="AnakiaTask.present"/>
    <!-- Check for Velocity version 1.5 -->
    <available classpathref="anakia.classpath" classname="org.apache.velocity.io.UnicodeInputStream" property="velocity.version.15"/>
    <antcall target="report-old-velocity"></antcall>
  </target>

  <target name="report-anakia-missing" depends="check-anakia" unless="AnakiaTask.present">
    <echo>
      AnakiaTask is not present, documentation will not be generated.
    </echo>
  </target>

  <target name="report-old-velocity" unless="velocity.version.15" if="AnakiaTask.present">
    <echo>
      Velocity version appears to be older than 1.5: the documentation may be generated with incorrect line endings.
    </echo>
  </target>

  <target name="compile-core" depends="compile-jorphan" description="Compile JMeter core classes.">
    <mkdir dir="${build.core}"/>
    <javac srcdir="${src.core}" destdir="${build.core}" optimize="${optimize}" source="${src.java.version}" debug="on" target="${target.java.version}"
           includeAntRuntime="${includeAntRuntime}" deprecation="${deprecation}" encoding="${encoding}">
      <include name="**/*.java"/>
      <classpath>
        <pathelement location="${build.jorphan}"/>
        <pathelement location="${lib.dir}/${log4j-core.jar}"/>
        <path refid="classpath"/>
        <path refid="logging.classpath"/>
      </classpath>
    </javac>

    <!-- Convert the message files from UTF-8 to ASCII. This can be removed
    after upgrading to Java 9+ as the minimum JRE and specifying the encoding
    when loading the ResourceBundles -->
    <native2ascii src="${src.core}" dest="${build.core}" includes="**/*.properties" encoding="UTF-8"/>
  </target>

  <target name="compile-components" depends="compile-jorphan,compile-core" description="Compile generic (protocol-independent) components.">
    <mkdir dir="${build.components}"/>
    <javac srcdir="${src.components}" destdir="${build.components}" source="${src.java.version}" optimize="${optimize}" debug="on" target="${target.java.version}"
           includeAntRuntime="${includeAntRuntime}" deprecation="${deprecation}" encoding="${encoding}">
      <include name="**/*.java"/>
      <exclude name="**/visualizers/RenderInBrowser.java" unless="javafx.present"/>
      <classpath>
        <pathelement location="${build.jorphan}"/>
        <pathelement location="${build.core}"/>
        <path refid="classpath"/>
      </classpath>
    </javac>

    <!-- Convert the message files from UTF-8 to ASCII. This can be removed
    after upgrading to Java 9+ as the minimum JRE and specifying the encoding
    when loading the ResourceBundles -->
    <native2ascii src="${src.components}" dest="${build.components}" includes="**/*.properties" encoding="UTF-8"/>
  </target>

  <target name="compile-functions" depends="compile-jorphan,compile-core" description="Compile functions.">
    <mkdir dir="${build.functions}"/>
    <javac srcdir="${src.functions}" destdir="${build.functions}" source="${src.java.version}" optimize="${optimize}" debug="on" target="${target.java.version}"
           includeAntRuntime="${includeAntRuntime}" deprecation="${deprecation}" encoding="${encoding}">
      <include name="**/*.java"/>
      <classpath>
        <pathelement location="${build.jorphan}"/>
        <pathelement location="${build.core}"/>
        <path refid="classpath"/>
      </classpath>
    </javac>

    <!-- Convert the message files from UTF-8 to ASCII. This can be removed
    after upgrading to Java 9+ as the minimum JRE and specifying the encoding
    when loading the ResourceBundles -->
    <native2ascii src="${src.functions}" dest="${build.functions}" includes="**/*.properties" encoding="UTF-8"/>
  </target>

  <target name="compile-http" depends="compile-jorphan,compile-core,compile-components" description="Compile components specific to HTTP sampling.">
    <mkdir dir="${build.http}"/>
    <!-- Directory needs to exist, or jar will fail -->
    <javac srcdir="${src.http}" destdir="${build.http}" source="${src.java.version}" optimize="${optimize}" debug="on" target="${target.java.version}"
           includeAntRuntime="${includeAntRuntime}" deprecation="${deprecation}" encoding="${encoding}">
      <include name="**/*.java"/>
      <classpath>
        <pathelement location="${build.jorphan}"/>
        <pathelement location="${build.core}"/>
        <pathelement location="${build.components}"/>
        <path refid="classpath"/>
        <pathelement location="${lib.dir}/${jcl-over-slf4j.jar}"/>
        <pathelement location="${lib.dir}/${log4j-api.jar}"/>
        <pathelement location="${lib.dir}/${log4j-core.jar}"/>
      </classpath>
    </javac>

    <!-- Convert the message files from UTF-8 to ASCII. This can be removed
    after upgrading to Java 9+ as the minimum JRE and specifying the encoding
    when loading the ResourceBundles -->
    <native2ascii src="${src.http}" dest="${build.http}" includes="**/*.properties" encoding="UTF-8"/>
  </target>

  <!-- Tests need main classes -->
  <target name="compile-tests" depends="compile" description="Compile test components">
    <mkdir dir="${build.test}"/>
    <javac srcdir="${src.test}" destdir="${build.test}" source="${src.java.version}" optimize="${optimize}" debug="on" target="${target.java.version}"
           includeAntRuntime="${includeAntRuntime}" deprecation="${deprecation}" encoding="${encoding}">
      <classpath>
        <pathelement location="${build.jorphan}"/>
        <pathelement location="${build.core}"/>
        <pathelement location="${build.components}"/>
        <pathelement location="${build.http}"/>
        <pathelement location="${build.ftp}"/>
        <pathelement location="${build.functions}"/>
        <pathelement location="${build.java}"/>
        <pathelement location="${build.jdbc}"/>
        <pathelement location="${build.jms}"/>
        <pathelement location="${build.ldap}"/>
        <pathelement location="${build.mail}"/>
        <pathelement location="${build.mongodb}"/>
        <pathelement location="${build.native}"/>
        <pathelement location="${build.tcp}"/>
        <!-- Also include compiled jars to allow running tests without rebuilding source -->
        <fileset dir="${dest.jar}" includes="*.jar"/>
        <path refid="classpath"/>
        <path refid="logging.classpath"/>
      </classpath>
    </javac>

    <!-- Convert the message files from UTF-8 to ASCII. This can be removed
    after upgrading to Java 9+ as the minimum JRE and specifying the encoding
    when loading the ResourceBundles -->
    <native2ascii src="${src.test}" dest="${build.test}" includes="**/*.properties" encoding="UTF-8"/>

    <!-- Compile Spock tests (groovy) -->
    <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc">
      <classpath>
        <fileset dir="${lib.dir}" includes="*.jar"/>
      </classpath>
    </taskdef>
    <groovyc srcdir="${src.test}" destdir="${build.test}" encoding="${encoding}" listfiles="true">
      <classpath>
        <pathelement location="${build.jorphan}"/>
        <pathelement location="${build.core}"/>
        <pathelement location="${build.components}"/>
        <pathelement location="${build.http}"/>
        <pathelement location="${build.ftp}"/>
        <pathelement location="${build.functions}"/>
        <pathelement location="${build.java}"/>
        <pathelement location="${build.jdbc}"/>
        <pathelement location="${build.ldap}"/>
        <pathelement location="${build.mail}"/>
        <pathelement location="${build.tcp}"/>
        <!-- Include compiled jars to allow running tests without rebuilding source -->
        <fileset dir="${dest.jar}" includes="*.jar"/>
        <path refid="classpath"/>
      </classpath>
      <!-- Compile JUnit tests (Java) -->
      <javac source="${src.java.version}" debug="on" target="${target.java.version}"
             deprecation="${deprecation}" encoding="${encoding}">
      </javac>
    </groovyc>
  </target>

  <target name="compile-ftp" depends="compile-jorphan,compile-core" description="Compile components specific to FTP sampling.">
    <mkdir dir="${build.ftp}"/>
    <javac srcdir="${src.ftp}" destdir="${build.ftp}" source="${src.java.version}" optimize="${optimize}" debug="on" target="${target.java.version}"
           includeAntRuntime="${includeAntRuntime}" deprecation="${deprecation}" encoding="${encoding}">
      <include name="**/*.java"/>
      <classpath>
        <pathelement location="${build.jorphan}"/>
        <pathelement location="${build.core}"/>
        <path refid="classpath"/>
      </classpath>
    </javac>

    <!-- Convert the message files from UTF-8 to ASCII. This can be removed
    after upgrading to Java 9+ as the minimum JRE and specifying the encoding
    when loading the ResourceBundles -->
    <native2ascii src="${src.ftp}" dest="${build.ftp}" includes="**/*.properties" encoding="UTF-8"/>
  </target>

  <target name="compile-jdbc" depends="compile-jorphan,compile-core" description="Compile components specific to JDBC sampling.">
    <mkdir dir="${build.jdbc}"/>
    <javac srcdir="${src.jdbc}" destdir="${build.jdbc}" source="${src.java.version}" optimize="${optimize}" debug="on" target="${target.java.version}"
           includeAntRuntime="${includeAntRuntime}" deprecation="${deprecation}" encoding="${encoding}">
      <include name="**/*.java"/>
      <classpath>
        <pathelement location="${build.jorphan}"/>
        <pathelement location="${build.core}"/>
        <path refid="classpath"/>
      </classpath>
    </javac>

    <!-- Convert the message files from UTF-8 to ASCII. This can be removed
    after upgrading to Java 9+ as the minimum JRE and specifying the encoding
    when loading the ResourceBundles -->
    <native2ascii src="${src.jdbc}" dest="${build.jdbc}" includes="**/*.properties" encoding="UTF-8"/>
  </target>

  <target name="compile-ldap" depends="compile-jorphan,compile-core"
    description="Compile components specific to LDAP sampling.">
    <mkdir dir="${build.ldap}"/>
    <javac srcdir="${src.ldap}" destdir="${build.ldap}" source="${src.java.version}" optimize="${optimize}" debug="on" target="${target.java.version}"
           includeAntRuntime="${includeAntRuntime}" deprecation="${deprecation}" encoding="${encoding}">
      <include name="**/*.java"/>
      <classpath>
        <pathelement location="${build.jorphan}"/>
        <pathelement location="${build.core}"/>
        <path refid="classpath"/>
      </classpath>
    </javac>

    <!-- Convert the message files from UTF-8 to ASCII. This can be removed
    after upgrading to Java 9+ as the minimum JRE and specifying the encoding
    when loading the ResourceBundles -->
    <native2ascii src="${src.ldap}" dest="${build.ldap}" includes="**/*.properties" encoding="UTF-8"/>
  </target>

  <target name="create-mail-dir">
    <mkdir dir="${build.mail}"/>
  </target>

  <target name="compile-mail" depends="compile-jorphan,compile-core,create-mail-dir"
    description="Compile components specific to IMAP and POP3 sampling.">
    <javac srcdir="${src.mail}" destdir="${build.mail}" source="${src.java.version}" optimize="${optimize}" debug="on" target="${target.java.version}"
           includeAntRuntime="${includeAntRuntime}" deprecation="${deprecation}" encoding="${encoding}">
      <include name="**/*.java"/>
      <classpath>
        <pathelement location="${build.jorphan}"/>
        <pathelement location="${build.core}"/>
        <path refid="classpath"/>
      </classpath>
    </javac>

    <!-- Convert the message files from UTF-8 to ASCII. This can be removed
    after upgrading to Java 9+ as the minimum JRE and specifying the encoding
    when loading the ResourceBundles -->
    <native2ascii src="${src.mail}" dest="${build.mail}" includes="**/*.properties" encoding="UTF-8"/>
  </target>

  <target name="compile-java" depends="compile-jorphan,compile-core" description="Compile components specific to Java sampling.">
    <mkdir dir="${build.java}"/>
    <javac srcdir="${src.java}" destdir="${build.java}" source="${src.java.version}" optimize="${optimize}" debug="on" target="${target.java.version}"
           includeAntRuntime="${includeAntRuntime}" deprecation="${deprecation}" encoding="${encoding}">
      <include name="**/*.java"/>
      <classpath>
        <pathelement location="${build.jorphan}"/>
        <pathelement location="${build.core}"/>
        <path refid="classpath"/>
      </classpath>
    </javac>

    <!-- Convert the message files from UTF-8 to ASCII. This can be removed
    after upgrading to Java 9+ as the minimum JRE and specifying the encoding
    when loading the ResourceBundles -->
    <native2ascii src="${src.java}" dest="${build.java}" includes="**/*.properties" encoding="UTF-8"/>
  </target>

  <target name="compile-junit" depends="compile-jorphan,compile-core" description="Compile components specific to JUnit sampling.">
    <mkdir dir="${build.junit}"/>
    <javac srcdir="${src.junit}" destdir="${build.junit}" source="${src.java.version}" optimize="${optimize}" debug="on" target="${target.java.version}"
           includeAntRuntime="${includeAntRuntime}" deprecation="${deprecation}" encoding="${encoding}">
      <include name="**/*.java"/>
      <classpath>
        <pathelement location="${build.jorphan}"/>
        <pathelement location="${build.core}"/>
        <path refid="classpath"/>
      </classpath>
    </javac>

    <!-- Convert the message files from UTF-8 to ASCII. This can be removed
    after upgrading to Java 9+ as the minimum JRE and specifying the encoding
    when loading the ResourceBundles -->
    <native2ascii src="${src.junit}" dest="${build.junit}" includes="**/*.properties" encoding="UTF-8"/>
  </target>

  <target name="compile-tcp" depends="compile-jorphan,compile-core" description="Compile components specific to TCP sampling.">
    <mkdir dir="${build.tcp}"/>
    <javac srcdir="${src.tcp}" destdir="${build.tcp}" source="${src.java.version}" optimize="${optimize}" debug="on" target="${target.java.version}"
           includeAntRuntime="${includeAntRuntime}" deprecation="${deprecation}" encoding="${encoding}">
      <include name="**/*.java"/>
      <classpath>
        <pathelement location="${build.jorphan}"/>
        <pathelement location="${build.core}"/>
        <path refid="classpath"/>
      </classpath>
    </javac>

    <!-- Convert the message files from UTF-8 to ASCII. This can be removed
    after upgrading to Java 9+ as the minimum JRE and specifying the encoding
    when loading the ResourceBundles -->
    <native2ascii src="${src.tcp}" dest="${build.tcp}" includes="**/*.properties" encoding="UTF-8"/>
  </target>

  <target name="compile-protocols" depends="compile-http,compile-ftp,compile-jdbc,compile-java,compile-ldap,compile-mail,compile-tcp" description="Compile all protocol-specific components."/>

  <target name="compile-examples" depends="compile-jorphan,compile-core" description="Compile example components.">
    <mkdir dir="${build.examples}"/>
    <javac srcdir="${src.examples}" destdir="${build.examples}" source="${src.java.version}" optimize="${optimize}" debug="on" target="${target.java.version}"
           includeAntRuntime="${includeAntRuntime}" deprecation="${deprecation}" encoding="${encoding}">
      <include name="**/*.java"/>
      <classpath>
        <pathelement location="${build.jorphan}"/>
        <pathelement location="${build.core}"/>
        <path refid="classpath"/>
      </classpath>
    </javac>

    <!-- Convert the message files from UTF-8 to ASCII. This can be removed
    after upgrading to Java 9+ as the minimum JRE and specifying the encoding
    when loading the ResourceBundles -->
    <native2ascii src="${src.examples}" dest="${build.examples}" includes="**/*.properties" encoding="UTF-8"/>
  </target>

  <target name="compile-jorphan" depends="init-version" description="Compile JOrphan utility classes.">
    <mkdir dir="${build.jorphan}"/>
    <javac srcdir="${src.jorphan}" destdir="${build.jorphan}" source="${src.java.version}" optimize="${optimize}" debug="on" target="${target.java.version}"
           includeAntRuntime="${includeAntRuntime}" deprecation="${deprecation}" encoding="${encoding}">
      <include name="**/*.java"/>
      <classpath>
        <path refid="classpath"/>
      </classpath>
    </javac>

    <!-- Convert the message files from UTF-8 to ASCII. This can be removed
    after upgrading to Java 9+ as the minimum JRE and specifying the encoding
    when loading the ResourceBundles -->
    <native2ascii src="${src.jorphan}" dest="${build.jorphan}" includes="**/*.properties" encoding="UTF-8"/>
  </target>

  <target name="compile-jms" depends="compile-jorphan,compile-core,compile-components"
        description="Compile components specific to JMS sampling.">
    <mkdir dir="${build.jms}"/>
    <javac srcdir="${src.jms}" destdir="${build.jms}" source="${src.java.version}" optimize="${optimize}" debug="on" target="${target.java.version}"
           includeAntRuntime="${includeAntRuntime}" deprecation="${deprecation}" encoding="${encoding}">
      <include name="**/*.java"/>
      <classpath>
        <pathelement location="${build.jorphan}"/>
        <pathelement location="${build.core}"/>
        <path refid="classpath"/>
      </classpath>
    </javac>

    <!-- Convert the message files from UTF-8 to ASCII. This can be removed
    after upgrading to Java 9+ as the minimum JRE and specifying the encoding
    when loading the ResourceBundles -->
    <native2ascii src="${src.jms}" dest="${build.jms}" includes="**/*.properties" encoding="UTF-8"/>
  </target>

  <target name="compile-native" depends="compile-jorphan,compile-core,compile-components"
        description="Compile components specific to Native sampling.">
    <mkdir dir="${build.native}"/>
    <javac srcdir="${src.native}" destdir="${build.native}" source="${src.java.version}" optimize="${optimize}" debug="on" target="${target.java.version}"
           includeAntRuntime="${includeAntRuntime}" deprecation="${deprecation}" encoding="${encoding}">
      <include name="**/*.java"/>
      <classpath>
        <pathelement location="${build.jorphan}"/>
        <pathelement location="${build.core}"/>
        <path refid="classpath"/>
      </classpath>
    </javac>

    <!-- Convert the message files from UTF-8 to ASCII. This can be removed
    after upgrading to Java 9+ as the minimum JRE and specifying the encoding
    when loading the ResourceBundles -->
    <native2ascii src="${src.native}" dest="${build.native}" includes="**/*.properties" encoding="UTF-8"/>
  </target>

  <target name="compile-mongodb" depends="compile-jorphan,compile-core,compile-components"
        description="Compile components specific to MongoDB sampling.">
    <mkdir dir="${build.mongodb}"/>
    <javac srcdir="${src.mongodb}" destdir="${build.mongodb}" source="${src.java.version}" optimize="${optimize}" debug="on" target="${target.java.version}"
           includeAntRuntime="${includeAntRuntime}" deprecation="${deprecation}" encoding="${encoding}">
      <include name="**/*.java"/>
      <classpath>
        <pathelement location="${build.jorphan}"/>
        <pathelement location="${build.core}"/>
        <path refid="classpath"/>
      </classpath>
    </javac>

    <!-- Convert the message files from UTF-8 to ASCII. This can be removed
    after upgrading to Java 9+ as the minimum JRE and specifying the encoding
    when loading the ResourceBundles -->
    <native2ascii src="${src.mongodb}" dest="${build.mongodb}" includes="**/*.properties" encoding="UTF-8"/>
  </target>

  <target name="compile"
  depends="_message_3rdParty,compile-core,compile-components,compile-functions,compile-protocols,compile-junit,compile-jms,compile-native, compile-mongodb"
  description="Compile everything."/>

  <target name="run_gui" depends="package" description="Run the JMeter GUI off the jar files">
    <condition property="jacoco_params" value="${jacocoagent}" else="-Djacoco_dummy=">
      <isset property="jacocoagent"/>
    </condition>
    <java classname="org.apache.jmeter.NewDriver" fork="true">
      <classpath>
        <pathelement location="${dest.jar.jmeter}/ApacheJMeter.jar"/>
      </classpath>
      <jvmarg value="-Xss256k"/>
      <jvmarg value="-XX:MaxMetaspaceSize=256m"/>
      <jvmarg value="${jacoco_params}run_gui:java(server)"/>
      <sysproperty key="jmeter.home" value="${basedir}"/>
    </java>
  </target>

  <target name="package" depends="compile, prepare-resources, package-only"
     description="Compile everything and create the jars"/>

  <target name="package-and-check" depends="clean, download_jars, package, checkstyle, rat"
     description="Compile, create jars and apply checkstyle before committing code"/>

  <target name="prepare-resources"
     description="Prepare some resources files, update date">
    <mkdir dir="${build.res}" />
    <mkdir dir="${resources.meta-inf}" />
    <copy todir="${resources.meta-inf}" overwrite="yes" filtering="yes"
        encoding="${encoding}">
      <filterset refid="year.filters"/>
      <filterset refid="version.filters" />
      <fileset dir="${res.dir}/META-INF" >
        <include name="*.license" />
        <include name="*.notice" />
        <include name="jmeter_as_ascii_art.txt" />
      </fileset>
    </copy>
    <fixcrlf encoding="${encoding}" srcdir="${resources.meta-inf}" eol="crlf" includes="*.license *.notice"/>
  </target>

<!--
N.B. Eclipse (and perhaps other Java IDEs) copies all files to the build directory, unless
told otherwise. This means that there might be copies of property and image files in the
build directory. To avoid including the files twice in the jar file, we include only .class
files in the list of files to be processed from the build tree.

Eclipse has been fixed so that it no longer shows files in the build tree in the Open Resource dialogue,
so having duplicates in the build tree no longer causes confusion.

Note: if built from Eclipse, the build directory will include resources and images,
and Eclipse will thus be able to run JMeter from the default path.

If built using Ant, the build tree will not contain any resources, and thus Eclipse will not be able to
run JMeter unless all the JMeter jars are added.

-->
  <target name="package-only" description="Package already-compiled classes (shortcut for IDE users)">
    <manifest file="${build.dir}/MANIFEST_BIN.MF">
      <attribute name="Built-By" value="${user.name}"/>
      <attribute name="Extension-Name" value=" JMeter"/>
      <attribute name="Specification-Title" value=" Apache JMeter"/>
      <attribute name="Specification-Vendor" value=" Apache Software Foundation"/>
      <attribute name="Implementation-Vendor" value=" Apache Software Foundation"/>
      <attribute name="Implementation-Vendor-Id" value=" org.apache"/>
      <attribute name="Implementation-Version" value="${implementation.version}"/>
      <attribute name="X-Compile-Source-JDK" value="${src.java.version}"/>
      <attribute name="X-Compile-Target-JDK" value="${target.java.version}"/>
    </manifest>

    <manifest file="${build.dir}/MANIFEST_SRC.MF">
      <attribute name="Built-By" value="${user.name}"/>
      <attribute name="Extension-Name" value=" JMeter"/>
      <attribute name="Specification-Title" value=" Apache JMeter"/>
      <attribute name="Specification-Vendor" value=" Apache Software Foundation"/>
      <attribute name="Implementation-Vendor" value=" Apache Software Foundation"/>
      <attribute name="Implementation-Vendor-Id" value=" org.apache"/>
      <attribute name="Implementation-Version" value="${implementation.version}"/>
   </manifest>

    <mkdir dir="${dest.jar}"/>

    <!-- perhaps ought to include a basic jmeter.properties file in one of the jars,
    given that JMeterUtils looks for it if it cannot find the external one
    - otherwise, change utils to ignore it -->

    <!-- JMeter launch jar -->
    <jar jarfile="${dest.jar.jmeter}/ApacheJMeter.jar"
        includes="**/NewDriver*,**/DynamicClassLoader*,**/ShutdownClient.class"
        basedir="${build.core}"
        manifest="${build.dir}/MANIFEST_BIN.MF">
      <manifest>
        <attribute name="Main-Class" value="org.apache.jmeter.NewDriver"/>
      </manifest>
      <zipfileset file="${resources.meta-inf}/default.notice"
          fullpath="META-INF/NOTICE" />
      <zipfileset file="${resources.meta-inf}/default.license"
          fullpath="META-INF/LICENSE" />
      <zipfileset file="${resources.meta-inf}/jmeter_as_ascii_art.txt"
          fullpath="org/apache/jmeter/jmeter_as_ascii_art.txt" />
    </jar>

    <!-- core -->
    <jar jarfile="${dest.jar}/ApacheJMeter_core.jar"
        manifest="${build.dir}/MANIFEST_BIN.MF">
      <zipfileset file="${resources.meta-inf}/default.notice"
        fullpath="META-INF/NOTICE" />
      <zipfileset file="${resources.meta-inf}/default.license"
        fullpath="META-INF/LICENSE" />
      <!-- add license details for images -->
      <zipfileset file="licenses/src/openiconlibrary.txt"
        fullpath="META-INF/LICENSE-openiconlibrary.txt" />
      <!-- Only include class files from build tree - see above -->
      <fileset dir="${build.core}" includes="**/*.class"
        excludes="**/BeanShellClient*.class,**/NewDriver*,**/DynamicClassLoader*,**/ShutdownClient.class"/>
      <fileset dir="${src.core}" includes="org/apache/jmeter/images/**"
        excludes="**/*.properties,org/apache/jmeter/images/toolbar/icons-custom/**"/>
      <fileset dir="${build.core}" includes="**/*.properties">
        <exclude name="*eucJP*"/>
      </fileset>
      <fileset dir="${src.core}" includes="**/*.xml" />
      <fileset dir="${src.core}" includes="**/*.xsl" />
      <fileset dir="${src.core}" includes="**/*.dtd" />
      <!-- This file is used by the jmeter -h option -->
      <fileset dir="${src.core}" includes="org/apache/jmeter/help.txt"/>
    </jar>

    <!-- components -->
    <jar jarfile="${dest.jar}/ApacheJMeter_components.jar" manifest="${build.dir}/MANIFEST_BIN.MF">
      <zipfileset file="${resources.meta-inf}/default.notice"
        fullpath="META-INF/NOTICE" />
      <zipfileset file="${resources.meta-inf}/default.license"
        fullpath="META-INF/LICENSE" />
      <fileset dir="${build.components}" includes="**/*.class" />
      <fileset dir="${build.components}" includes="**/*.properties" />
    </jar>

    <!-- functions -->
    <jar jarfile="${dest.jar}/ApacheJMeter_functions.jar" manifest="${build.dir}/MANIFEST_BIN.MF">
      <zipfileset file="${resources.meta-inf}/default.notice"
        fullpath="META-INF/NOTICE" />
      <zipfileset file="${resources.meta-inf}/default.license"
        fullpath="META-INF/LICENSE" />
      <fileset dir="${build.functions}" includes="**/*.class" />
      <fileset dir="${build.functions}" includes="**/*.properties" />
    </jar>

    <!-- http -->
    <jar jarfile="${dest.jar}/ApacheJMeter_http.jar" manifest="${build.dir}/MANIFEST_BIN.MF">
      <zipfileset file="${resources.meta-inf}/default.notice"
        fullpath="META-INF/NOTICE" />
      <zipfileset file="${resources.meta-inf}/default.license"
        fullpath="META-INF/LICENSE" />
      <fileset dir="${build.http}" includes="**/*.class"/>
      <fileset dir="${build.http}" includes="**/*.properties" />
    </jar>

    <!-- ftp -->
    <jar jarfile="${dest.jar}/ApacheJMeter_ftp.jar" manifest="${build.dir}/MANIFEST_BIN.MF">
      <zipfileset file="${resources.meta-inf}/default.notice"
        fullpath="META-INF/NOTICE" />
      <zipfileset file="${resources.meta-inf}/default.license"
        fullpath="META-INF/LICENSE" />
      <fileset dir="${build.ftp}" includes="**/*.class" />
      <fileset dir="${build.ftp}" includes="**/*.properties" />
    </jar>

    <!-- jdbc -->
    <jar jarfile="${dest.jar}/ApacheJMeter_jdbc.jar" manifest="${build.dir}/MANIFEST_BIN.MF">
      <zipfileset file="${resources.meta-inf}/default.notice"
        fullpath="META-INF/NOTICE" />
      <zipfileset file="${resources.meta-inf}/default.license"
        fullpath="META-INF/LICENSE" />
      <fileset dir="${build.jdbc}" includes="**/*.class" />
      <fileset dir="${build.jdbc}" includes="**/*.properties" />
    </jar>

    <!-- java -->
    <jar jarfile="${dest.jar}/ApacheJMeter_java.jar" manifest="${build.dir}/MANIFEST_BIN.MF">
      <zipfileset file="${resources.meta-inf}/default.notice"
        fullpath="META-INF/NOTICE" />
      <zipfileset file="${resources.meta-inf}/default.license"
        fullpath="META-INF/LICENSE" />
      <fileset dir="${build.java}" includes="**/*.class" />
      <fileset dir="${build.java}" includes="**/*.properties" />
    </jar>

    <!-- BeanShell Client -->
    <jar jarfile="${lib.dir}/bshclient.jar" manifest="${build.dir}/MANIFEST_BIN.MF">
      <manifest>
         <attribute name="Main-Class" value="org.apache.jmeter.util.BeanShellClient"/>
      </manifest>
      <zipfileset file="${resources.meta-inf}/default.notice"
        fullpath="META-INF/NOTICE" />
      <zipfileset file="${resources.meta-inf}/default.license"
        fullpath="META-INF/LICENSE" />
      <fileset dir="${build.core}" includes="**/BeanShellClient*.class" />
    </jar>

    <!-- junit -->
    <jar jarfile="${dest.jar}/ApacheJMeter_junit.jar" manifest="${build.dir}/MANIFEST_BIN.MF">
      <zipfileset file="${resources.meta-inf}/default.notice"
        fullpath="META-INF/NOTICE" />
      <zipfileset file="${resources.meta-inf}/default.license"
        fullpath="META-INF/LICENSE" />
      <fileset dir="${build.junit}" includes="org/**/*.class" />
      <fileset dir="${build.junit}" includes="**/*.properties" />
    </jar>

    <!-- Build junit/test.jar sample -->
    <jar jarfile="${lib.dir}/junit/test.jar" manifest="${build.dir}/MANIFEST_BIN.MF">
      <zipfileset file="${resources.meta-inf}/default.notice"
        fullpath="META-INF/NOTICE" />
      <zipfileset file="${resources.meta-inf}/default.license"
        fullpath="META-INF/LICENSE" />
      <fileset dir="${build.junit}" excludes="org/**/*" />
      <fileset dir="${src.junit}"   excludes="org/**/*" />
    </jar>

    <!-- ldap -->
    <jar jarfile="${dest.jar}/ApacheJMeter_ldap.jar" manifest="${build.dir}/MANIFEST_BIN.MF">
      <zipfileset file="${resources.meta-inf}/default.notice"
        fullpath="META-INF/NOTICE" />
      <zipfileset file="${resources.meta-inf}/default.license"
        fullpath="META-INF/LICENSE" />
      <fileset dir="${build.ldap}" includes="**/*.class" />
      <fileset dir="${build.ldap}" includes="**/*.properties" />
    </jar>

    <!-- mail -->
    <jar jarfile="${dest.jar}/ApacheJMeter_mail.jar" manifest="${build.dir}/MANIFEST_BIN.MF">
      <zipfileset file="${resources.meta-inf}/default.notice"
        fullpath="META-INF/NOTICE" />
      <zipfileset file="${resources.meta-inf}/default.license"
        fullpath="META-INF/LICENSE" />
      <fileset dir="${build.mail}" includes="**/*.class"  />
      <fileset dir="${build.mail}" includes="**/*.properties" />
      <fileset dir="${src.mail}" includes="**/*.providers" />
    </jar>

    <!-- tcp -->
    <jar jarfile="${dest.jar}/ApacheJMeter_tcp.jar" manifest="${build.dir}/MANIFEST_BIN.MF">
      <zipfileset file="${resources.meta-inf}/default.notice"
        fullpath="META-INF/NOTICE" />
      <zipfileset file="${resources.meta-inf}/default.license"
        fullpath="META-INF/LICENSE" />
      <fileset dir="${build.tcp}" includes="**/*.class" />
      <fileset dir="${build.tcp}" includes="**/*.properties" />
    </jar>

    <!-- jms -->
    <!-- Ensure that build dir exists, even if JMS has not been built -->
    <mkdir dir="${build.jms}"/>
    <jar jarfile="${dest.jar}/ApacheJMeter_jms.jar" manifest="${build.dir}/MANIFEST_BIN.MF">
      <zipfileset file="${resources.meta-inf}/default.notice"
        fullpath="META-INF/NOTICE" />
      <zipfileset file="${resources.meta-inf}/default.license"
        fullpath="META-INF/LICENSE" />
      <fileset dir="${build.jms}" includes="**/*.class" />
      <fileset dir="${build.jms}" includes="**/*.properties" />
    </jar>

    <!-- native -->
    <!-- Ensure that build dir exists, even if Native has not been built -->
    <mkdir dir="${build.native}"/>
    <jar jarfile="${dest.jar}/ApacheJMeter_native.jar" manifest="${build.dir}/MANIFEST_BIN.MF">
      <zipfileset file="${resources.meta-inf}/default.notice"
        fullpath="META-INF/NOTICE" />
      <zipfileset file="${resources.meta-inf}/default.license"
        fullpath="META-INF/LICENSE" />
      <fileset dir="${build.native}" includes="**/*.class" />
      <fileset dir="${build.native}" includes="**/*.properties" />
    </jar>

    <!-- mongodb -->
    <!-- Ensure that build dir exists, even if MongoDB has not been built -->
    <mkdir dir="${build.mongodb}"/>
    <jar jarfile="${dest.jar}/ApacheJMeter_mongodb.jar" manifest="${build.dir}/MANIFEST_BIN.MF">
      <zipfileset file="${resources.meta-inf}/default.notice"
        fullpath="META-INF/NOTICE" />
      <zipfileset file="${resources.meta-inf}/default.license"
        fullpath="META-INF/LICENSE" />
      <fileset dir="${build.mongodb}" includes="**/*.class" />
      <fileset dir="${build.mongodb}" includes="**/*.properties" />
    </jar>

    <jar jarfile="${lib.dir}/jorphan.jar" manifest="${build.dir}/MANIFEST_BIN.MF">
      <zipfileset file="${resources.meta-inf}/default.notice"
          fullpath="META-INF/NOTICE" />
      <zipfileset file="${resources.meta-inf}/default.license"
          fullpath="META-INF/LICENSE" />
      <fileset dir="${build.jorphan}" includes="**/*.class"/>
      <fileset dir="${build.jorphan}" includes="**/*.properties"/>
    </jar>
  </target>

  <!-- Check the Ant version -->
  <available property="Ant-1.8.0-or-later" classname="org.apache.tools.ant.taskdefs.Local"/>
  <fail message="This build requires Ant 1.8.0 or later" unless="Ant-1.8.0-or-later"/>

  <!-- Check that the 3rd party libraries are present -->
  <target name="_check_3rdparty">
    <condition property="3rdparty.present">
      <and>
        <!-- No need to check all jars; just check a few -->
        <available classpathref="classpath" classname="org.apache.bsf.BSFEngine"/>
        <available classpathref="classpath" classname="com.thoughtworks.xstream.XStream"/>
      </and>
    </condition>
  </target>

  <target name="_message_3rdParty" depends="_check_3rdparty" unless="3rdparty.present">
    <echo>Cannot find all the required 3rd party libraries.</echo>
    <echo>If building from a release, you can get most of them from the binary archive.</echo>
    <echo>Use "ant download_jars" to download any missing jars.</echo>
    <fail message="Cannot find required classes"/>
  </target>

  <target name="setup-eclipse-project" description="Setup eclipse project to contribute to JMeter">
    <echo>Creating eclipse project</echo>
    <copy overwrite="false" file="eclipse.project" tofile=".project" />
    <copy overwrite="false" file="eclipse.classpath" tofile=".classpath"/>
    <input message="Next step will download dependencies for JMeter, do you agree with the download ?" addproperty="do.download" validargs="y,n"/>
    <condition property="do.abort">
      <equals arg1="n" arg2="${do.download}"/>
    </condition>
    <fail message="You didn't agree to download dependencies, ensure you call Ant target 'download_jars when importing project" if="do.abort"/>
    <echo>Downloading dependencies</echo>
    <antcall target="download_jars" />
    <echo>Project has been successfully created, you can now import it in Eclipse using Right click > Import > Existing projects into Workspace</echo>
  </target>

  <target name="install" depends="package,docs-printable" description="Install JMeter. (Compiles code and creates jars)">
    <fixcrlf encoding="${encoding}" srcdir="." eol="lf" includes="bin/*.sh bin/jmeter bin/jmeter-server bin/mirror-server"/>
    <chmod perm="+x" dir="." includes="${dist.executables}"/>
  </target>

  <target name="install-examples" depends="compile-examples" description="Build and installs the example components.">
    <jar jarfile="${dest.jar}/ApacheJMeter_examples.jar" manifest="${build.dir}/MANIFEST_BIN.MF">
      <zipfileset file="${resources.meta-inf}/default.notice"
        fullpath="META-INF/NOTICE" />
      <zipfileset file="${resources.meta-inf}/default.license"
        fullpath="META-INF/LICENSE" />
      <fileset dir="${build.examples}" includes="**/*.class" />
      <fileset dir="${build.examples}" includes="**/*.properties" />
    </jar>
  </target>

  <!-- lists of files needed for a binary distribution (excluding library files) -->
  <!-- Source files also needed at runtime -->
  <patternset id="dist.common.native">
    <include name="${dest.jar.jmeter}/BeanShell*.bshrc"/>
    <include name="${dest.jar.jmeter}/jaas.conf"/>
    <include name="${dest.jar.jmeter}/krb5.conf"/>
    <include name="${dest.jar.jmeter}/hc.parameters"/>
    <include name="${dest.jar.jmeter}/jmeter.properties"/>
    <include name="${dest.jar.jmeter}/log4j2.xml"/>
    <include name="${dest.jar.jmeter}/reportgenerator.properties"/>
    <include name="${dest.jar.jmeter}/upgrade.properties"/>
    <include name="${dest.jar.jmeter}/saveservice.properties"/>
    <include name="${dest.jar.jmeter}/users.dtd"/>
    <include name="${dest.jar.jmeter}/users.xml"/>
    <!-- Sample override properties files -->
    <include name="${dest.jar.jmeter}/httpclient.parameters"/>
    <include name="${dest.jar.jmeter}/system.properties"/>
    <include name="${dest.jar.jmeter}/user.properties"/>
    <!-- Exclude any files that might be present from testing the release -->
    <exclude name="${dest.jar.jmeter}/*.log"/>
    <exclude name="${dest.jar.jmeter}/rmi_keystore.jks"/>
    <include name="${dest.jar.jmeter}/examples/**"/>
    <include name="${dest.jar.jmeter}/templates/*.dtd"/>
    <!-- report-templates files which need to have native eol -->
    <include name="${dest.jar.jmeter}/report-template/README.TXT"/>
    <include name="${dest.jar.jmeter}/report-template/**/*.fmkr"/>
    <include name="${dest.jar.jmeter}/report-template/content/**/*.css"/>
    <include name="${dest.jar.jmeter}/report-template/content/**/*.js"/>
    <!-- JMX files are in the non-native section -->
    <exclude name="${dest.jar.jmeter}/examples/*.jmx"/>
    <include name="${extras.dir}/**"/>
    <!-- Binary file types -->
    <exclude name="${extras.dir}/*.jar"/>
    <exclude name="${extras.dir}/*.jpg"/>
    <exclude name="${extras.dir}/*.png"/>
    <!-- File types that need to retain their EOL setting -->
    <exclude name="${extras.dir}/*.jmx"/>
    <exclude name="${extras.dir}/*.cmd"/>
    <exclude name="${extras.dir}/*.sh"/>
  </patternset>

  <patternset id="dist.binaries.native">
    <include name="LICENSE"/>
    <include name="licenses/**"/>
    <include name="NOTICE"/>
    <include name="README.md"/>
    <patternset refid="dist.common.native"/>
    <!-- Help documentation -->
    <include name="${dest.printable_docs}/**"/>
    <!-- Binary file types -->
    <exclude name="${dest.printable_docs}/**/*.pdf"/>
    <exclude name="${dest.printable_docs}/**/*.jmx"/>
    <!-- We also need the shared CSS for the printable docs -->
    <include name="${dest.docs}/css/**"/>
  </patternset>

  <!-- Source files also needed at runtime -->
  <patternset id="dist.common.non.native">
    <include name="${dest.jar.jmeter}/heapdump.*"/>
    <include name="${dest.jar.jmeter}/jmeter*"/>
    <exclude name="${dest.jar.jmeter}/jmeter.properties"/>
    <exclude name="${dest.jar.jmeter}/reportgenerator.properties"/>
    <include name="${dest.jar.jmeter}/mirror-server*"/>
    <include name="${dest.jar.jmeter}/shutdown.*"/>
    <include name="${dest.jar.jmeter}/stoptest.*"/>
    <include name="${dest.jar.jmeter}/create-rmi-keystore.*"/>
    <!-- Fake SSL cert for JMeter proxy recorder in https -->
    <include name="${dest.jar.jmeter}/proxyserver.jks"/>
    <!-- Exclude any files that might be present from testing the release -->
    <exclude name="${dest.jar.jmeter}/*.log"/>
    <exclude name="${dest.jar.jmeter}/rmi_keystore.jks"/>
    <!-- report-template files non native -->
    <include name="${dest.jar.jmeter}/report-template/content/pages/*.png"/>
    <include name="${dest.jar.jmeter}/report-template/sbadmin2*/**"/>
    <include name="${dest.jar.jmeter}/templates/*.jmx"/>
    <include name="${dest.jar.jmeter}/templates/*.xml"/>
    <include name="${dest.jar.jmeter}/examples/*.jmx"/>
    <include name="${extras.dir}/*.jar"/>
    <include name="${extras.dir}/*.jpg"/>
    <include name="${extras.dir}/*.png"/>
    <!-- File types that need to retain their EOL setting -->
    <include name="${extras.dir}/*.jmx"/>
    <include name="${extras.dir}/*.cmd"/>
    <include name="${extras.dir}/*.sh"/>
  </patternset>

  <patternset id="dist.binaries.non.native">
    <patternset refid="dist.common.non.native"/>
    <include name="${dest.jar}/"/>
    <include name="${lib.dir}/bshclient.jar"/>
    <include name="${lib.dir}/jorphan.jar"/>
    <include name="${lib.dir}/junit/test.jar"/>
    <include name="${dest.jar.jmeter}/ApacheJMeter.jar"/>
    <!-- Help documentation, binary files -->
    <include name="${dest.printable_docs}/**/*.pdf"/>
    <include name="${dest.printable_docs}/**/*.jmx"/>
    <!-- We also need the shared images for the printable docs -->
    <include name="${dest.docs}/images/**"/>
  </patternset>

  <!--
      List of Unix executable files in the binary distribution
      These need special handling to create the correct file mode
  -->
  <property name="dist.executables"
    value="${dest.jar.jmeter}/jmeter ${dest.jar.jmeter}/jmeter-server ${dest.jar.jmeter}/mirror-server ${dest.jar.jmeter}/*.sh ${extras.dir}/*.sh"/>

  <!-- List of files in source distribution that are eol=native -->
  <!--
  N.B. dist.sources[.non].native sets exclude source files present in dist.binaries[.non].native
  so that the nightly build src archive does not duplicate stuff in the binary archive
  (This may change, as the overlap does not waste much space)
  -->
  <patternset id="dist.sources.native">
    <include name="LICENSE"/>
    <!-- Include all the licenses; they are needed to build the distribution -->
    <include name="licenses/**"/>
    <include name="NOTICE"/>
    <include name="README.md"/>
    <include name="${src.dir}/**"/>
    <exclude name="**/messages.metaprops"/>
    <!-- Exclude binary types -->
    <exclude name="**/*.gif"/>
    <exclude name="**/*.jpg"/>
    <exclude name="**/*.png"/>
    <include name="${src.docs}/**"/>
    <!-- Include some resources -->
    <include name="${res.dir}/**"/>
    <!-- Exclude binary types (and JMX/JTL, which are not OS-dependent) -->
    <exclude name="${src.docs}/images/**"/>
    <exclude name="${src.docs}/**/*.jmx"/>
    <exclude name="${src.docs}/**/*.odt"/>
    <exclude name="${src.docs}/**/*.pdf"/>
    <exclude name="${src.docs}/**/*.sxi"/>
    <exclude name="${src.docs}/**/*.sxw"/>
    <include name="${src.test}/**"/>
    <include name="build.xml"/>
    <include name="build.properties"/>
    <include name="${dest.jar.jmeter}/*.groovy"/>
    <include name="${dest.jar.jmeter}/testfiles/**"/>
    <exclude name="${dest.jar.jmeter}/testfiles/*.jmx"/>
    <exclude name="${dest.jar.jmeter}/testfiles/*.jtl"/>
    <!-- These are generated with EOL=LF -->
    <exclude name="${dest.jar.jmeter}/testfiles/*.xml"/>
    <!-- Ignore unit test output -->
    <exclude name="${dest.jar.jmeter}/testfiles/*.out"/>
    <exclude name="${dest.jar.jmeter}/testfiles/Sample_*.png"/>
    <include name="eclipse.classpath"/>
    <include name="eclipse.project"/>
    <include name="eclipse.md"/>
    <include name=".gitignore"/>
    <include name=".travis.yml"/>
    <include name="checkstyle.xml"/>
    <include name="checkstyle-suppressions.xml"/>
    <include name="rat-excludes.txt"/>
    <include name="${build.test-res}/**"/>
    <include name="${lib.dir}/aareadme.txt"/>
    <include name="${lib.dir}/**/readme.txt"/>
    <include name="fb-*.x*"/>
    <!-- Make sure that the lib/opt directory is included in the archives -->
    <include name="${lib.opt}/README.txt"/>
  </patternset>

  <!-- Non-native items -->
  <patternset id="dist.sources.non.native">
    <include name="${src.dir}/**/*.gif"/>
    <include name="${src.dir}/**/*.jpg"/>
    <include name="${src.dir}/**/*.png"/>
    <include name="${src.docs}/images/**"/>
    <include name="${src.docs}/**/*.jmx"/>
    <include name="${src.docs}/**/*.odt"/>
    <include name="${src.docs}/**/*.pdf"/>
    <include name="${src.docs}/**/*.sxi"/>
    <include name="${src.docs}/**/*.sxw"/>
    <include name="${dest.jar.jmeter}/testfiles/*.jmx"/>
    <include name="${dest.jar.jmeter}/testfiles/*.jtl"/>
    <!-- These are generated with EOL=LF -->
    <include name="${dest.jar.jmeter}/testfiles/*.xml"/>
    <!-- Include the image files used in parsing / embedded download tests -->
    <include name="${dest.jar.jmeter}/testfiles/**/*.gif"/>
    <include name="${dest.jar.jmeter}/testfiles/**/*.jpg"/>
    <include name="${dest.jar.jmeter}/testfiles/**/*.png"/>
  </patternset>

    <!-- Convert eol:native source files to appropriate format if required -->
    <target name="_filter" unless="native.${eoltype}">
      <property name="workdir" value="${dist.dir}/${eoltype}"/>
      <echo level="info">Converting work files to eol=${eoltype} in ${workdir}</echo>
      <mkdir dir="${workdir}"/>
      <copy includeemptydirs="false" todir="${workdir}" encoding="${encoding}">
        <fileset dir=".">
          <patternset refid="${fileset}"/>
        </fileset>
        <filterchain>
          <fixcrlf encoding="${encoding}" fixlast="false" eol="${eoltype}" srcdir="${workdir}"/>
        </filterchain>
      </copy>
    </target>

    <!-- Files to be included in full source download -->
    <patternset id="dist_src_files_native">
      <patternset refid="dist.sources.native"/>
      <patternset refid="dist.common.native"/>
    </patternset>

    <patternset id="dist_src_files_non_native">
      <patternset refid="dist.sources.non.native"/>
      <patternset refid="dist.common.non.native"/>
    </patternset>

    <!-- Files to be included in full binary download -->
    <patternset id="dist_bin_files_native">
      <patternset refid="dist.binaries.native"/>
      <patternset refid="external.jars.notices"/>
      <!-- We don't need the site docs, but we do want Javadoc (e.g. for BeanShell) -->
      <include name="${dest.docs.api}/**"/>
      <exclude name="${dest.docs.api}/resources/**"/>
    </patternset>

    <patternset id="dist_bin_files_non_native">
      <patternset refid="dist.binaries.non.native"/>
      <patternset refid="external.jars"/>
      <include name="${dest.docs.api}/resources/**"/>
    </patternset>

    <!-- NOTE: the site documents are not included in either archive -->

    <!-- Invoke with -Djmeter.version=m.n -Duser.name=xyz@apache.org [-Dsvn.revision=nnnnn] [-Ddisplay.version=xxxx]
    Creates clean build and all documentation
    Creates runtime and source distributions and site documentation
    -->
    <target name="distribution"
        depends="ant-version,svnCheck,check-versions,clean,install,docs-printable,docs-api,test,_distribution"
        description="Build JMeter for end-user distribution"/>

    <target name="check-versions" unless="disable-check-versions">
      <fail message="jmeter.version must be defined" unless="jmeter.version"/>
      <fail message="svn.revision must be defined" unless="svn.revision"/>
      <local         name="version.match"/>
      <condition property="version.match">
        <resourcecontains resource="${src.core}/org/apache/jmeter/util/JMeterVersion.java"
                substring='VERSION = "${jmeter.version}";'/>
      </condition>
      <fail message="jmeter.version (${jmeter.version}) must be same as JMeterVersion.VERSION" unless="version.match"/>
    </target>

    <!--
    <target
        name="nightly"
        depends="init-svnVersion,package,docs-printable,pack-nightly"
        description="Build JMeter for nightly dir (package docs-printable pack-nightly)"/>
    -->
   <target
        name="nightly-setup"
        description="Disables some checks"
        depends="clean,clean-docs,clean-apidocs,clean-dist">
      <property name="disable-check-versions" value="true" />
      <property name="docs.force" value="true" />
    </target>
    <target
        name="nightly"
        depends="ant-version,nightly-setup,init-svnVersion,install,docs-printable,docs-api,test,_distribution"
        description="Build JMeter for nightly distribution (include docs)"/>

    <target name="_eolcheck">
      <!-- Determine if the native format is CRLF or LF (or neither) -->
      <condition property="native.lf">
        <os family="unix"/>
      </condition>
      <condition property="native.crlf">
        <os family="dos"/>
      </condition>
      <!-- Define native.dir.x as either the source or updated directory as appropriate -->
      <condition property="native.dir.lf" value="." else="${dist.dir}/lf">
        <isset property="native.lf"/>
      </condition>
      <condition property="native.dir.crlf" value="." else="${dist.dir}/crlf">
        <isset property="native.crlf"/>
      </condition>
      <echoproperties prefix="native"></echoproperties>
    </target>

    <!-- Internal target -->
    <target name="_distribution" depends="check-versions,_eolcheck,check_jars">
    <property name="dist.name" value="apache-jmeter-${jmeter.version}"/>
    <property name="pack.name" value="${dist.name}"/>
    <echo level="info">Creating JMeter distribution ${dist.name} ${svn.revision}</echo>
    <mkdir dir="${dist.dir}"/>

    <!-- Delete work directories just in case -->
    <delete dir="${dist.dir}/crlf" quiet="true"/>
    <delete dir="${dist.dir}/lf" quiet="true"/>

    <!-- Runtime archives -->
    <antcall target="_filter">
      <param name="eoltype" value="lf"/>
      <param name="fileset" value="dist_bin_files_native"/>
    </antcall>

    <tar destfile="${dist.dir}/${pack.name}.tar" longfile="gnu">
      <tarfileset dir="." prefix="${dist.name}" excludes="${dist.executables}" defaultexcludes="yes">
        <patternset refid="dist_bin_files_non_native"/>
      </tarfileset>
      <tarfileset mode="755" includes="${dist.executables}" dir="." prefix="${dist.name}" defaultexcludes="yes"/>
      <tarfileset dir="${native.dir.lf}" prefix="${dist.name}">
        <patternset refid="dist_bin_files_native"/>
      </tarfileset>
    </tar>
    <!-- Delete work directory (may not exist) -->
    <delete dir="${dist.dir}/lf" quiet="true"/>

    <gzip destfile="${dist.dir}/${pack.name}.tgz" src="${dist.dir}/${pack.name}.tar" />
    <!-- no longer needed -->
    <delete file="${dist.dir}/${pack.name}.tar"/>
    <antcall target="_hash">
      <param name="path" value="${dist.dir}/${dist.name}.tgz"/>
    </antcall>

    <antcall target="_filter">
      <param name="eoltype" value="crlf"/>
      <param name="fileset" value="dist_bin_files_native"/>
    </antcall>
    <zip  destfile="${dist.dir}/${pack.name}.zip">
      <zipfileset excludes="${dist.executables}" dir="." prefix="${dist.name}" defaultexcludes="yes">
        <patternset refid="dist_bin_files_non_native"/>
      </zipfileset>
      <zipfileset filemode="755" dir="." includes="${dist.executables}" prefix="${dist.name}" defaultexcludes="yes"/>
      <zipfileset dir="${native.dir.crlf}" prefix="${dist.name}">
        <patternset refid="dist_bin_files_native"/>
      </zipfileset>
    </zip>
    <antcall target="_hash">
      <param name="path" value="${dist.dir}/${dist.name}.zip"/>
    </antcall>
    <!-- Delete work directory (may not exist) -->
    <delete dir="${dist.dir}/crlf" quiet="true"/>

    <!-- Source archives -->
    <antcall target="_filter">
      <param name="eoltype" value="lf"/>
      <param name="fileset" value="dist_src_files_native"/>
    </antcall>
    <tar destfile="${dist.dir}/${pack.name}_src.tar" longfile="gnu">
      <tarfileset dir="${native.dir.lf}" prefix="${dist.name}">
        <patternset refid="dist_src_files_native"/>
      </tarfileset>
      <tarfileset excludes="${dist.executables}" dir="." prefix="${dist.name}" defaultexcludes="yes">
        <patternset refid="dist_src_files_non_native"/>
      </tarfileset>
      <tarfileset mode="755" includes="${dist.executables}" dir="." prefix="${dist.name}" defaultexcludes="yes"/>
    </tar>
    <!-- Delete work directory (may not exist) -->
    <delete dir="${dist.dir}/lf" quiet="true"/>

    <gzip destfile="${dist.dir}/${pack.name}_src.tgz" src="${dist.dir}/${pack.name}_src.tar" />
    <!-- no longer needed -->
    <delete file="${dist.dir}/${pack.name}_src.tar"/>
    <antcall target="_hash">
      <param name="path" value="${dist.dir}/${dist.name}_src.tgz"/>
    </antcall>

    <antcall target="_filter">
      <param name="eoltype" value="crlf"/>
      <param name="fileset" value="dist_src_files_native"/>
    </antcall>

    <zip  destfile="${dist.dir}/${pack.name}_src.zip">
      <zipfileset dir="${native.dir.crlf}" prefix="${dist.name}">
        <patternset refid="dist_src_files_native"/>
      </zipfileset>
      <zipfileset excludes="${dist.executables}" dir="." prefix="${dist.name}" defaultexcludes="yes">
        <patternset refid="dist_src_files_non_native"/>
      </zipfileset>
      <zipfileset filemode="755" includes="${dist.executables}" dir="." prefix="${dist.name}" defaultexcludes="yes"/>
    </zip>
    <antcall target="_hash">
      <param name="path" value="${dist.dir}/${dist.name}_src.zip"/>
    </antcall>
    <!-- Delete work directory (may not exist) -->
    <delete dir="${dist.dir}/crlf" quiet="true"/>
  </target>

  <!-- Set up files for distribution to Maven via Nexus -->
  <target name="_dist_maven" depends="init-version">
    <!-- Ensure there aren't any stale files left -->
    <delete dir="${maven.dir}" includes="*.pom" quiet="true"/>
    <echo>Updating POM files to version ${jmeter.version}</echo>
    <copy todir="${maven.dir}">
      <fileset dir="${maven.poms}" includes="*.pom"/>
      <filterset>
        <filter token="MAVEN.DEPLOY.VERSION" value="${jmeter.version}"/>
      </filterset>
    </copy>
    <delete dir="${maven.dir}" includes="*.jar" quiet="true"/>
    <echo>Copying jar files ready for signing</echo>
    <copy todir="${maven.dir}">
      <fileset dir="${dest.jar}" includes="ApacheJMeter*.jar"/>
      <fileset dir="${dest.jar.jmeter}" includes="ApacheJMeter.jar"/>
      <fileset dir="${lib.dir}" includes="jorphan.jar"/>
    </copy>
    <copy tofile="${maven.dir}/ApacheJMeter_junit-test.jar" file="${lib.dir}/junit/test.jar"/>
    <!--
        Create the Maven jar needed to hold configuration data
        Cannot be added to any of the other jars as that would cause problems for stand-alone JMeter usage.
    -->
    <jar jarfile="${maven.dir}/ApacheJMeter_config.jar" manifest="${build.dir}/MANIFEST_SRC.MF">
      <zipfileset file="${resources.meta-inf}/default.notice"
          fullpath="META-INF/NOTICE" />
      <zipfileset file="${resources.meta-inf}/default.license"
          fullpath="META-INF/LICENSE" />
      <zipfileset dir="${dest.jar.jmeter}" prefix="bin" includes="*.bshrc"/>
      <zipfileset dir="${dest.jar.jmeter}" prefix="bin" includes="*.groovy"/>
      <zipfileset dir="${dest.jar.jmeter}" prefix="bin" includes="*.parameters"/>
      <zipfileset dir="${dest.jar.jmeter}" prefix="bin" includes="*.properties"/>
      <zipfileset dir="${dest.jar.jmeter}" prefix="bin" includes="jaas.conf"/>
      <zipfileset dir="${dest.jar.jmeter}" prefix="bin" includes="krb5.conf"/>
      <zipfileset dir="${dest.jar.jmeter}" prefix="bin" includes="log4j2.xml"/>
      <zipfileset dir="${dest.jar.jmeter}" prefix="bin" includes="proxyserver.jks"/>
      <zipfileset dir="${dest.jar.jmeter}" prefix="bin" includes="users.dtd"/>
      <zipfileset dir="${dest.jar.jmeter}" prefix="bin" includes="templates/templates.dtd"/>
      <zipfileset dir="${dest.jar.jmeter}" prefix="bin" includes="users.xml"/>
      <zipfileset dir="${dest.jar.jmeter}" prefix="bin" includes="report-template/**/*.*" />
    </jar>
    <antcall target="generate_src_artifacts" />
    <antcall target="generate_javadoc_artifacts" />
  </target>

  <target name="generate_src_artifacts">
      <jar destfile="${maven.dir}/ApacheJMeter-sources.jar">
          <fileset dir="${src.core}" includes="**/NewDriver*.java,**/DynamicClassLoader*.java,**/ShutdownClient.java"
              excludes="**/*.png,**/*.xml,**/*.properties,**/*.txt,**/.html" />
      </jar>
      <jar destfile="${maven.dir}/ApacheJMeter_core-sources.jar">
          <fileset dir="${src.core}" excludes="**/NewDriver*.java,**/DynamicClassLoader*.java,**/ShutdownClient.java,**/*.png,**/*.xml,**/*.properties,**/*.txt,**/.html" />
      </jar>
      <generate_src_artifact artifactname="ApacheJMeter_http" srcdir="${src.http}" targetdir="${maven.dir}" />
      <generate_src_artifact artifactname="ApacheJMeter_ftp" srcdir="${src.ftp}" targetdir="${maven.dir}" />
      <generate_src_artifact artifactname="ApacheJMeter_jdbc" srcdir="${src.jdbc}" targetdir="${maven.dir}" />
      <generate_src_artifact artifactname="ApacheJMeter_java" srcdir="${src.java}" targetdir="${maven.dir}" />
      <generate_src_artifact artifactname="ApacheJMeter_junit" srcdir="${src.junit}" targetdir="${maven.dir}" />
      <generate_src_artifact artifactname="ApacheJMeter_components" srcdir="${src.components}" targetdir="${maven.dir}" />
      <generate_src_artifact artifactname="ApacheJMeter_functions" srcdir="${src.functions}" targetdir="${maven.dir}" />
      <generate_src_artifact artifactname="jorphan" srcdir="${src.jorphan}" targetdir="${maven.dir}" />
      <generate_src_artifact artifactname="ApacheJMeter_ldap" srcdir="${src.ldap}" targetdir="${maven.dir}" />
      <generate_src_artifact artifactname="ApacheJMeter_tcp" srcdir="${src.tcp}" targetdir="${maven.dir}" />
      <generate_src_artifact artifactname="ApacheJMeter_mail" srcdir="${src.mail}" targetdir="${maven.dir}" />
      <generate_src_artifact artifactname="ApacheJMeter_jms" srcdir="${src.jms}" targetdir="${maven.dir}" />
      <generate_src_artifact artifactname="ApacheJMeter_native" srcdir="${src.native}" targetdir="${maven.dir}" />
      <generate_src_artifact artifactname="ApacheJMeter_mongodb" srcdir="${src.mongodb}" targetdir="${maven.dir}" />
  </target>
  <macrodef name="generate_src_artifact">
    <attribute name="artifactname"/>
    <attribute name="srcdir" />
    <attribute name="targetdir"/>
    <sequential>
        <jar destfile="@{targetdir}/@{artifactname}-sources.jar">
            <fileset dir="@{srcdir}" includes="**/*.java" excludes="**/*.png,**/*.xml,**/*.properties,**/*.txt,**/.html"/>
        </jar>
    </sequential>
  </macrodef>
    
  <target name="generate_javadoc_artifacts">
      <generate_javadoc_artifact artifactname="ApacheJMeter_core" srcdir="${src.core}" targetdir="${maven.dir}" />
      <generate_javadoc_artifact artifactname="ApacheJMeter_http" srcdir="${src.http}" targetdir="${maven.dir}" />
      <generate_javadoc_artifact artifactname="ApacheJMeter_ftp" srcdir="${src.ftp}" targetdir="${maven.dir}" />
      <generate_javadoc_artifact artifactname="ApacheJMeter_jdbc" srcdir="${src.jdbc}" targetdir="${maven.dir}" />
      <generate_javadoc_artifact artifactname="ApacheJMeter_java" srcdir="${src.java}" targetdir="${maven.dir}" />
      <generate_javadoc_artifact artifactname="ApacheJMeter_junit" srcdir="${src.junit}" targetdir="${maven.dir}" />
      <generate_javadoc_artifact artifactname="ApacheJMeter_components" srcdir="${src.components}" targetdir="${maven.dir}" />
      <generate_javadoc_artifact artifactname="ApacheJMeter_functions" srcdir="${src.functions}" targetdir="${maven.dir}" />
      <generate_javadoc_artifact artifactname="jorphan" srcdir="${src.jorphan}" targetdir="${maven.dir}" />
      <generate_javadoc_artifact artifactname="ApacheJMeter_ldap" srcdir="${src.ldap}" targetdir="${maven.dir}" />
      <generate_javadoc_artifact artifactname="ApacheJMeter_tcp" srcdir="${src.tcp}" targetdir="${maven.dir}" />
      <generate_javadoc_artifact artifactname="ApacheJMeter_mail" srcdir="${src.mail}" targetdir="${maven.dir}" />
      <generate_javadoc_artifact artifactname="ApacheJMeter_jms" srcdir="${src.jms}" targetdir="${maven.dir}" />
      <generate_javadoc_artifact artifactname="ApacheJMeter_native" srcdir="${src.native}" targetdir="${maven.dir}" />
      <generate_javadoc_artifact artifactname="ApacheJMeter_mongodb" srcdir="${src.mongodb}" targetdir="${maven.dir}" />
  </target>
  <macrodef name="generate_javadoc_artifact">
      <attribute name="artifactname"/>
      <attribute name="srcdir" />
      <attribute name="targetdir"/>
      <attribute name="additionalclasspath" default="${maven.dir}"/>
      <sequential>
        <mkdir dir="@{targetdir}/@{artifactname}" />
        <local name="THISYEAR" />
        <tstamp>
          <!-- Used to ensure end-year is up to date -->
          <format property="THISYEAR" pattern="yyyy"/>
        </tstamp>
          <javadoc 
              sourcepath="@{srcdir}"
            additionalparam="-breakiterator -notimestamp"
            destdir="@{targetdir}/@{artifactname}"
            encoding="${javadoc.encoding}"
            verbose="false"
            protected="yes"
            version="yes"
            doctitle="Apache JMeter @{artifactname} API"
            windowtitle="Apache JMeter @{artifactname} API"
            header="&lt;b&gt;Apache JMeter&lt;/b&gt;"
            bottom="Copyright &amp;#xA9; 1998-${THISYEAR} Apache Software Foundation. All Rights Reserved.">
            <classpath>
              <path refid="classpath"/>
              <path refid="logging.classpath"/>
              <fileset dir="@{additionalclasspath}">
                <include name="*.jar" />
              </fileset>
            </classpath>
            <link href="http://docs.oracle.com/javase/8/docs/api/"/>
          </javadoc>
        <jar destfile="@{targetdir}/@{artifactname}-javadoc.jar">
          <fileset dir="@{targetdir}/@{artifactname}" includes="**/*.*" />
        </jar>
        <delete failonerror="true" dir="@{targetdir}/@{artifactname}" />
      </sequential>
  </macrodef>
  <!--
      Beanshell script to create the svnmucc scripts for upload, delete and publish.

      The generated script assumes svnmucc is invoked with a root URL of
      https://dist.apache.org/repos/dist/
      This means that the jmeter files are at:
      dev/jmeter/[binaries|source]
      and
      release/jmeter/[binaries|source]
  -->
  <scriptdef name="svnmuccScript" language="beanshell">
    <classpath>
      <pathelement location="${lib.dir}/${beanshell.jar}"/>
    </classpath>
    <!-- type of script to create: upload, publish or delete -->
    <attribute name="type"/>
    <!-- Name of file to create -->
    <attribute name="tempfile"/>
    <![CDATA[
    void upload(source) {
      self.log("Will upload " + source + " to " + RCdir);
      outstream.println("put");
      outstream.println(source); // source
      outstream.print("dev/jmeter/");
      outstream.print(RCdir);
      outstream.println(source); // dest
      outstream.println();
    }
    void publish(source, targetDir) {
      self.log("Will publish " + source + " to " + targetDir);
      outstream.println("mv");
      outstream.print("dev/jmeter/");
      outstream.print(RCdir);
      outstream.println(source); // source
      outstream.print("release/jmeter/");
      outstream.print(targetDir);
      outstream.println(source); // source
      outstream.println();
    }
    void delete(source, targetDir) {
      self.log("Will delete " + source + " from " + targetDir);
      outstream.println("rm");
      outstream.print("release/jmeter/");
      outstream.print(targetDir);
      outstream.println(source); // source
      outstream.println();
    }
    void processFiles(basename, targetDir) {
      // combine all the extensions in one list
      extensions = new String[]{".zip", ".zip.asc", ".zip.sha512", ".tgz", ".tgz.asc", ".tgz.sha512"};
      for (i = 0; i < extensions.length; ++i) {
        extension = extensions[i];
        srcFile = basename + extension;

        if ("upload".equals(type)) {
            upload(srcFile);
        } else if ("publish".equals(type)) {
            publish(srcFile, targetDir);
        } else if ("delete".equals(type)) {
            delete(srcFile, targetDir);
        }
      }
    }
      type = attributes.get("type");
      RCdir = "";
      RC="";
      version = "";
      if (type.equals("delete")) {
        version = project.getProperty("jmeter.old.version");
      } else {
        version = project.getProperty("jmeter.version");
        RC = project.getProperty("RC");
        RCdir = "v"+version+"_"+RC+"/";
      }
      tempfile = attributes.get("tempfile");
      self.log("Writing " + type + " script for version " + version + " " + RC + " into " + tempfile);
      distname = project.getProperty("dist.name");
      outstream = new PrintStream(new File(tempfile));
      if ("upload".equals(type)) { // make the initial directory
        outstream.println("mkdir");
        outstream.print("dev/jmeter/");
        outstream.println(RCdir);
        outstream.println();
      }
      processFiles(distname, "binaries/");
      processFiles(distname+"_src", "source/");
      // TODO could remove RCdir, but safer to do that manually after checking it is empty
      outstream.close();
    ]]>
  </scriptdef>

  <!--
      Run svnnmucc against the svnpubsub distribution area
  -->
  <target name="_svnmucc">
    <property name="repoType" value="test"/>
    <condition property="repo"
            value="https://dist.apache.org/repos/dist/"
            else="https://svn.apache.org/repos/asf/jmeter/test/" >
      <equals arg1="live" arg2="${repoType}"/>
    </condition>
    <echo level="info">Processing ${tempfile} using svnmucc on repo: ${repoType}</echo>
    <echo level="info">${repo}</echo>
    <echo level="info">${message}</echo>
    <!-- Only one of the following will execute -->
    <antcall target="_svnmucc_storedPass"/>
    <antcall target="_svnmucc_providedPass"/>
  </target>

  <!-- run svnmucc using stored credentials -->
  <target name="_svnmucc_storedPass" unless="asf.ldap.password">
    <echo level="info" message="Using stored credentials"/>
    <exec executable="svnmucc" dir="${dist.dir}" logerror="true" failonerror="true" failifexecutionfails="true">
      <arg value="--non-interactive"/> <!-- -n alias was removed in svnmucc 1.8.0 -->
      <!-- not strictly necessary, but does no harm and agrees with password version -->
      <arg value="--no-auth-cache"/>
      <arg value="--message"/> <!-- -m -->
      <arg value="${message}"/>
      <arg value="--root-url"/> <!-- -U -->
      <arg value="${repo}"/>
      <arg value="--extra-args"/> <!-- -X -->
      <arg value="${tempfile}"/>
    </exec>
  </target>

  <!-- run svnmucc using password provided as a property -->
  <target name="_svnmucc_providedPass" if="asf.ldap.password">
    <!-- provide default user name -->
    <property name="asf.ldap.username" value="${user.name}"/>
    <echo level="info" message="Using provided credentials for user ${asf.ldap.username}"/>
    <exec executable="svnmucc" dir="${dist.dir}" logerror="true" failonerror="true" failifexecutionfails="true">
      <arg value="--non-interactive"/>
      <!-- we don't want to cache the provided credentials -->
      <arg value="--no-auth-cache"/>
      <arg value="--message"/> <!-- -m -->
      <arg value="${message}"/>
      <arg value="--root-url"/> <!-- -U -->
      <arg value="${repo}"/>
      <arg value="--extra-args"/> <!-- -X -->
      <arg value="${tempfile}"/>
      <!-- Add credentials provided on command-line -->
      <arg value="--username"/> <!-- -u -->
      <arg value="${asf.ldap.username}"/>
      <arg value="--password"/> <!-- -p -->
      <arg value="${asf.ldap.password}"/>
    </exec>
  </target>

  <!--
        Targets for deploying release candidates via svnpubsub.

        By default, deploys the artifacts under the JMeter test repo:
        https://svn.apache.org/repos/asf/jmeter/test/

        The live repo is:
        https://dist.apache.org/repos/dist/

        The JMeter files are to be found under:

        dev/jmeter/[source|binaries]
        and
        release/jmeter/[source|binaries]

        Files that are expected to be present:
        apache-jmeter-<version>.[tgz|zip] + [.asc|.sha512]
        apache-jmeter-<version>_src.[tgz|zip] + [.asc|.sha512]

        Must have SVN installed, in particular the svnmucc command-line client.


        Pre-requisites:
        The distribution files must have been built and signed and placed in the dist/ directory.
        If any required files are missing, then upload will fail.

        Usage:
          ant RC_upload  [-DrepoType=test|live] [-Djmeter.version=2.9] -DRC=RCn [-Dasf.ldap.password=secret [-Dasf.ldap.usermame=user] ]
          ant RC_publish [-DrepoType=test|live] [-Djmeter.version=2.9] -DRC=RCn [-Dasf.ldap.password=secret [-Dasf.ldap.usermame=user] ]
          ant release_delete  [-DrepoType=test|live]  -Djmeter.old.version=2.8      [-Dasf.ldap.password=secret [-Dasf.ldap.usermame=user] ]
          (the old version must be specified and different from the current version!)

        If the ldap password is not provided, svnmucc is invoked without the username (-u) and password (-p) parameters.
        In this case, svnmucc will use whatever stored credentials are present for the svn host.

        If not using stored credentials, provide at least the ldap password.
        The ldap username defaults to the login name (i.e. the Java user.name property) but can also be provided.

        Note: svnmucc can only move or copy files where the target does not exist.
        This is perfect for deploying an RC or new release as these use unique names.
        However, any existing files such as HEADER.html will need to be handled separately.
  -->


  <target name="RC_upload"
    description="Upload release candidate to svnpubsub area. Params: [-DrepoType=test|live] [-Djmeter.version=m.n] -DRC=RCn [-Dasf.ldap.password=secret -Dasf.ldap.usermame=user]"
    depends="init-version">
    <fail message="RC property must be defined!" unless="RC"/>
    <echo>Version = ${jmeter.version} ${RC}</echo>
    <property name="dist.name" value="apache-jmeter-${jmeter.version}"/>
    <property name="tempfile" value="svnmucc_upload.tmp"/>
    <svnmuccScript type="upload" tempfile="${dist.dir}/${tempfile}"/>
    <antcall target="_svnmucc">
      <param name="message" value="Uploading release candidate ${dist.name} to dev area"/>
    </antcall>
  </target>

  <target name="RC_publish"
    description="Publish release candidate from svnpubsub area. Params: [-DrepoType=test|live] [-Djmeter.version=m.n] -DRC=RCn [-Dasf.ldap.password=secret -Dasf.ldap.usermame=user]"
    depends="init-version">
    <fail message="RC property must be defined!" unless="RC"/>
    <echo>Version = ${jmeter.version} ${RC}</echo>
    <property name="dist.name" value="apache-jmeter-${jmeter.version}"/>
    <property name="tempfile" value="svnmucc_publish.tmp"/>
    <svnmuccScript type="publish" tempfile="${dist.dir}/${tempfile}"/>
    <antcall target="_svnmucc">
      <param name="message" value="Publishing ${dist.name} ${RC}"/>
    </antcall>
  </target>

  <target name="release_delete"
    description="Delete old release candidate from svnpubsub area. : [-DrepoType=test|live] -Djmeter.old.version=m.n [-Dasf.ldap.user=name -Dasf.ldap.password=secret]"
    depends="init-version">
    <fail message="jmeter.old.version property must be defined!" unless="jmeter.old.version"/>
    <condition property="same">
      <equals arg1="${jmeter.old.version}" arg2="${jmeter.version}"/>
    </condition>
    <echo>Old Version = ${jmeter.old.version}</echo>
    <fail message="jmeter.old.version must be different from current jmeter.version!" if="same"/>
    <property name="dist.name" value="apache-jmeter-${jmeter.old.version}"/>
    <property name="tempfile" value="svnmucc_delete.tmp"/>
    <svnmuccScript type="delete" tempfile="${dist.dir}/${tempfile}"/>
    <antcall target="_svnmucc">
      <param name="message" value="Deleting old release ${dist.name}"/>
    </antcall>
  </target>

  <!--
        Upload jars/poms/sigs to local (/target), snapshots or releases repos; default is local.
        By default, deploys the artifacts to target/deploy under JMeter home.

        Must have Maven 2.2.1 or Maven 3.0.x installed.
        The environment variable M2_HOME must point to a suitable Maven installation (2.2.1+)

        For remote deployment, username/password will need to be set up in the appropriate
        "server" entries in the Maven settings.xml file, i.e. under:

        apache.snapshots.https
        apache.releases.https

        Pre-requisite:
        The jars and poms need to be made available. If this has not already been done as part of
        creating the distribution (e.g. a snapshot release is desired), then invoke the following:

              ant _dist_maven -Djmeter.version=2.9-SNAPSHOT

        For non-SNAPSHOT releases, the jars and poms need to be signed (TODO document how!!)

        Usage:
              ant maven_upload [-DrepoType=snapshots|releases]
  -->
  <target name="maven_upload" description="Upload Maven jars and poms (and sigs if present) to Nexus.">

    <property environment="env"/>
    <!-- According to http://maven.apache.org/download.html#Installation M2_HOME applies to Maven 2.2.1 and 3.0.x -->
    <condition property="maven.present">
      <or>
        <isset property="env.M2_HOME"/>
        <isset property="maven.home"/> <!-- Allow override on command-line -->
      </or>
    </condition>
    <fail unless="${maven.present}"
      message="The environment variable M2_HOME (or property maven.home) must point to a Maven installation"/>

    <property name="maven.home" value="${env.M2_HOME}"/>

    <!-- file repo url -->
    <property name="file.url" value="file:${basedir}/target/deploy"/>

    <!-- Apache Nexus snapshots repo url -->
    <property name="snapshots.url" value="https://repository.apache.org/content/repositories/snapshots"/>
    <!-- Apache Nexus snapshots repo name for servers section of settings.xml -->
    <property name="snapshots.repositoryId" value="apache.snapshots.https"/>

    <!-- Apache Nexus releases repo url -->
    <property name="releases.url" value="https://repository.apache.org/service/local/staging/deploy/maven2"/>
    <!-- Apache Nexus releases repo name for servers section of settings.xml -->
    <property name="releases.repositoryId" value="apache.releases.https"/>

    <property name="repoType" value="file"/>

    <!-- Hack to skip defining files/types/classifiers -->
    <condition property="XX" value="" else="XX">
      <and>
        <available file="${maven.dir}/jorphan.jar.asc"/>
        <available file="${maven.dir}/jorphan.pom.asc"/>
        <!-- Don't upload sigs to snapshots repo (might mislead users) -->
        <not>
          <equals arg1="snapshots" arg2="@repoType"/>
        </not>
      </and>
    </condition>

    <!-- Derived from:
         http://maven.apache.org/ant-tasks/examples/mvn.html#Using_the_Java_Task
    -->
    <macrodef name="deployfile">
      <attribute name="stem" />
      <attribute name="packaging" default="jar"/>
      <attribute name="type" default="${repoType}"/>
      <attribute name="url" default="${@{type}.url}"/>
      <attribute name="repositoryId" default="${@{type}.repositoryId}"/>
      <sequential>
        <local name="artifact_has_source"/>
        <local name="artifact_has_javadoc"/>
        <condition property="artifact_has_source" value="" else="XX">
          <and>
            <available file="${maven.dir}/@{stem}-sources.jar"/>
          </and>
        </condition>
        <condition property="artifact_has_javadoc" value="" else="XX">
          <and>
            <available file="${maven.dir}/@{stem}-javadoc.jar"/>
          </and>
        </condition>
        <echo>Artifact @{stem} => artifact_has_source='${artifact_has_source}', artifact_has_javadoc='${artifact_has_javadoc}'</echo>
        <java classname="org.codehaus.classworlds.Launcher"
              fork="true"
              dir="${basedir}"
              failonerror="true">
          <jvmarg value="-Xmx256m"/>
          <classpath>
            <fileset dir="${maven.home}/boot">
              <include name="*.jar" />
            </fileset>
            <fileset dir="${maven.home}/lib">
              <include name="*.jar" />
            </fileset>
          </classpath>
          <sysproperty key="classworlds.conf" value="${maven.home}/bin/m2.conf" />
          <sysproperty key="maven.home" value="${maven.home}" />
          <!-- The following property must be defined for Maven 3.3.[123] at least -->
          <sysproperty key="maven.multiModuleProjectDirectory" value="${maven.home}"/>
          <arg value="--batch-mode"/>
          <!--arg value="-X"/-->
          <arg value="-DgeneratePom=false"/>
          <arg value="-Durl=@{url}"/>
          <arg value="-DrepositoryId=@{repositoryId}"/>
          <arg value="-DpomFile=${maven.dir}/@{stem}.pom"/>
          <!-- if artifact has no sources artifact_has_source=XX so -D will be ignored  -->
          <arg value="-D${artifact_has_source}sources=${maven.dir}/@{stem}-sources.jar"/>
          <!-- if artifact has no javadoc artifact_has_javadoc=XX so -D will be ignored  -->
          <arg value="-D${artifact_has_javadoc}javadoc=${maven.dir}/@{stem}-javadoc.jar"/>  
          <arg value="-Dpackaging=@{packaging}"/>
          <arg value="-Dfile=${maven.dir}/@{stem}.${packaging}"/>
          <!--
               The XX property is a hack to avoid creating conditional code.
               It will be empty if the sigs exist; if not it will be XX which will be ignored by Maven
          -->
          <!-- If packaging == pom, this will just upload the pom twice. Simpler than trying to conditionalise. -->
          <arg value="-D${XX}files=${maven.dir}/@{stem}.${packaging}.asc,${maven.dir}/@{stem}.pom.asc,${maven.dir}/@{stem}-sources.jar.asc,${maven.dir}/@{stem}-javadoc.jar.asc"/>
          <arg value="-D${XX}types=${packaging}.asc,pom.asc,-sources.jar.asc,-javadoc.jar.asc"/>
          <arg value="-D${XX}classifiers=,"/>
<!--
          <arg value="-D${artifact_has_source}files=${maven.dir}/@{stem}-sources.jar.asc"/>
          <arg value="-D${artifact_has_source}types=-sources.jar.asc"/>
          <arg value="-D${artifact_has_source}classifiers="/>
          <arg value="-D${artifact_has_javadoc}files=${maven.dir}/@{stem}-javadoc.jar.asc"/>
          <arg value="-D${artifact_has_javadoc}types=-javadoc.jar.asc"/>
          <arg value="-D${artifact_has_javadoc}classifiers="/>
-->
          <!-- Need at least version 2.7 of the plugin to upload additional files-->
          <arg value="org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file"/>
        </java>
      </sequential>
    </macrodef>

    <deployfile stem="ApacheJMeter_parent" packaging="pom"/>
    <deployfile stem="jorphan"/>
    <deployfile stem="ApacheJMeter"/>
    <deployfile stem="ApacheJMeter_components"/>
    <deployfile stem="ApacheJMeter_config"/>
    <deployfile stem="ApacheJMeter_core"/>
    <deployfile stem="ApacheJMeter_ftp"/>
    <deployfile stem="ApacheJMeter_functions"/>
    <deployfile stem="ApacheJMeter_http"/>
    <deployfile stem="ApacheJMeter_java"/>
    <deployfile stem="ApacheJMeter_jdbc"/>
    <deployfile stem="ApacheJMeter_jms"/>
    <deployfile stem="ApacheJMeter_junit"/>
    <deployfile stem="ApacheJMeter_junit-test"/>
    <deployfile stem="ApacheJMeter_ldap"/>
    <deployfile stem="ApacheJMeter_mail"/>
    <deployfile stem="ApacheJMeter_mongodb"/>
    <deployfile stem="ApacheJMeter_native"/>
    <deployfile stem="ApacheJMeter_tcp"/>
  </target>

  <!--
  Gump targets.
  There are separate build and test projects for the jmeter module.
  -->
  <!-- Used by project jmeter-cvs -->
  <target name="gump-build"
      depends="_gump_properties,clean,install"
      description="Build JMeter">
    <property name="dist.name" value="apache-jmeter-${jmeter.version}"/>
    <available file="${velocity.jar}" property="velocity.present"/>
    <!-- No need to create the archives for Gump
    <antcall target="_pack-binaries"/>
    <antcall target="_pack-libraries"/>
    <antcall target="_pack-source"/>
    -->
  </target>

  <!-- Used by project jmeter-test -->
  <target name="gump-test"
      depends="_gump_properties,compile-tests,_test"
      description="Test JMeter in Gump">
    <!-- Show the log file
    <concat>
      <filelist dir="bin" files="jmeter-test.log" />
    </concat>
     -->
  </target>

  <target name="_gump_properties">
    <echo level="info">
 Gump properties for this run
  jmeter.version      = ${jmeter.version}
  gump.run            = ${gump.run}
  date.projectfile    = ${date.projectfile}
  version.projectfile = ${version.projectfile}
 Build file:
  version.build       = ${version.build}
 Java properties:
  target.java.version = ${target.java.version}
  src.java.version    = ${src.java.version}
  optimize            = ${optimize}
  deprecation         = ${deprecation}
  encoding            = ${encoding}
    </echo>
    <echoproperties prefix="ant"/>
    <echoproperties prefix="gump"/>
    <echoproperties prefix="os"/>
    <echoproperties prefix="java."/>
    <echoproperties prefix="user."/>

  </target>

  <target name="pack-src" depends="init-version">
    <property name="dist.name" value="apache-jmeter-${jmeter.version}"/>
    <antcall target="_pack-source"/>
  </target>

  <target name="pack-dist" depends="init-version">
    <property name="dist.name" value="apache-jmeter-${jmeter.version}"/>
    <antcall target="_pack-binaries"/>
    <antcall target="_pack-libraries"/>
    <antcall target="_pack-javadoc"/>
    <antcall target="_pack-source"/>
  </target>

  <!-- As pack-dist but without javadoc -->
  <target name="pack-nightly" depends="init-version">
    <property name="dist.name" value="apache-jmeter-${jmeter.version}"/>
    <antcall target="_pack-binaries"/>
    <antcall target="_pack-libraries"/>
    <antcall target="_pack-source"/>
  </target>

  <target name="_pack-binaries">
    <property name="pack.name" value="${dist.name}_bin"/>
    <mkdir dir="${dist.dir}"/>
    <tar destfile="${dist.dir}/${pack.name}.tar" longfile="gnu">
      <tarfileset dir="." prefix="${dist.name}" excludes="${dist.executables}" defaultexcludes="yes">
        <patternset refid="dist.binaries.native"/>
      </tarfileset>
      <tarfileset dir="." prefix="${dist.name}" excludes="${dist.executables}" defaultexcludes="yes">
        <patternset refid="dist.binaries.non.native"/>
      </tarfileset>
      <tarfileset mode="755" includes="${dist.executables}" dir="." prefix="${dist.name}" defaultexcludes="yes"/>
    </tar>
    <gzip destfile="${dist.dir}/${pack.name}.tgz" src="${dist.dir}/${pack.name}.tar" />
    <!-- no longer needed -->
    <delete file="${dist.dir}/${pack.name}.tar"/>
    <zip  destfile="${dist.dir}/${pack.name}.zip">
      <zipfileset dir="." prefix="${dist.name}" defaultexcludes="yes">
        <patternset refid="dist.binaries.native"/>
      </zipfileset>
      <zipfileset dir="." prefix="${dist.name}" defaultexcludes="yes">
        <patternset refid="dist.binaries.non.native"/>
      </zipfileset>
    </zip>
  </target>

  <target name="_pack-libraries">
    <property name="pack.name" value="${dist.name}_lib"/>
    <mkdir dir="${dist.dir}"/>
    <tar destfile="${dist.dir}/${pack.name}.tar" longfile="gnu">
      <tarfileset dir="." prefix="${dist.name}" defaultexcludes="yes">
        <patternset refid="external.jars.notices"/>
      </tarfileset>
      <tarfileset dir="." prefix="${dist.name}" defaultexcludes="yes">
        <patternset refid="external.jars"/>
      </tarfileset>
    </tar>
    <gzip destfile="${dist.dir}/${pack.name}.tgz" src="${dist.dir}/${pack.name}.tar" />
    <!-- no longer needed -->
    <delete file="${dist.dir}/${pack.name}.tar"/>
    <zip  destfile="${dist.dir}/${pack.name}.zip">
      <zipfileset dir="." prefix="${dist.name}" defaultexcludes="yes">
        <patternset refid="external.jars.notices"/>
      </zipfileset>
      <zipfileset dir="." prefix="${dist.name}" defaultexcludes="yes">
        <patternset refid="external.jars"/>
      </zipfileset>
    </zip>
  </target>

  <target name="_pack-javadoc">
    <property name="pack.name" value="${dist.name}_api"/>
    <mkdir dir="${dist.dir}"/>
    <tar destfile="${dist.dir}/${pack.name}.tar" longfile="gnu">
      <tarfileset includes="${dest.docs.api}" dir="." prefix="${dist.name}" defaultexcludes="yes"/>
    </tar>
    <gzip destfile="${dist.dir}/${pack.name}.tgz" src="${dist.dir}/${pack.name}.tar" />
    <!-- no longer needed -->
    <delete file="${dist.dir}/${pack.name}.tar"/>
    <zip  destfile="${dist.dir}/${pack.name}.zip">
       <zipfileset includes="${dest.docs.api}" dir="." prefix="${dist.name}" defaultexcludes="yes"/>
    </zip>
  </target>

  <target name="_pack-source">
    <property name="pack.name" value="${dist.name}_src"/>
    <mkdir dir="${dist.dir}"/>
    <tar destfile="${dist.dir}/${pack.name}.tar" longfile="gnu">
      <tarfileset dir="." prefix="${dist.name}" defaultexcludes="yes">
        <patternset refid="dist.sources.native"/>
      </tarfileset>
      <tarfileset dir="." prefix="${dist.name}" defaultexcludes="yes">
        <patternset refid="dist.sources.non.native"/>
      </tarfileset>
    </tar>
    <gzip destfile="${dist.dir}/${pack.name}.tgz" src="${dist.dir}/${pack.name}.tar" />
    <!-- no longer needed -->
    <delete file="${dist.dir}/${pack.name}.tar"/>
    <zip  destfile="${dist.dir}/${pack.name}.zip">
      <zipfileset dir="." prefix="${dist.name}" defaultexcludes="yes">
        <patternset refid="dist.sources.native"/>
      </zipfileset>
      <zipfileset dir="." prefix="${dist.name}" defaultexcludes="yes">
        <patternset refid="dist.sources.non.native"/>
      </zipfileset>
    </zip>
  </target>

  <!-- Create a zip of all resource files for translators -->
  <target name="pack-resources">
    <mkdir dir="${dist.dir}"/>
    <zip  destfile="${dist.dir}/resources.zip">
      <zipfileset dir="." defaultexcludes="yes">
        <patternset excludes="${src.dir}/examples/**" />
        <patternset includes="${src.dir}/**/*Resources.properties" />
        <patternset includes="${src.dir}/**/messages.properties" />
        <patternset includes="${src.dir}/**/i18nedit.properties" />
      </zipfileset>
    </zip>
  </target>

<!--
    Utility target to create SHA-512 checksums in standard format (with *filename)
    Usage:
    <antcall target="_hash">
        <param name="path" value="archive.jar|zip|gz"/>
    </antcall>
-->

  <target name="_hash" unless="hash.skip">
    <basename property="_base" file="${path}"/>
    <echo message="Creating SHA-512 for ${path}"/>
    <checksum algorithm="SHA-512" file="${path}" property="sha512"/>
    <echo message="${sha512} *${_base}" file="${path}.sha512"/>
  </target>

  <!--
  Clean-docs and clean-apidocs can be used to empty the docs or docs/api directories.
  This should be done before regenerating the documents for a release so that any obsolete files are detected.
  -->
  <target name="clean-docs">
    <delete>
      <fileset dir="${dest.docs}" excludes=".svn/** api/**"/>
    </delete>
  </target>

  <!-- Use this before running docs-print to ensure image files are synchronised -->
  <target name="clean-docs-images">
    <delete failonerror="false">
      <fileset dir="${dest.docs}/images" excludes=".svn/**"/>
    </delete>
  </target>

  <target name="clean-apidocs">
    <delete failonerror="false">
      <fileset dir="${dest.docs.api}" excludes=".svn/**" />
    </delete>
  </target>

  <target name="clean" description="Clean up to force a build from source.">
    <!-- Unfortunately Ant reports failure if a directory does not exist -->
    <delete quiet="false" failonerror="false">
      <fileset dir="${dest.jar.jmeter}" includes="ApacheJMeter.jar"/>
      <fileset dir="${lib.dir}" includes="jorphan.jar"/>
      <fileset dir="${lib.dir}" includes="bshclient.jar"/>
      <fileset dir="${dest.jar}" includes="*.jar"/>
      <fileset dir="${build.dir}"/>
      <fileset dir="${dest.printable_docs}"/>
      <fileset dir="${dist.dir}"/>
    </delete>
  </target>

  <target name="clean-dist" description="Clean up dist directory.">
    <delete quiet="true">
      <fileset dir="${dist.dir}"/>
    </delete>
  </target>

  <target name="docs-api" description="Generate the API documentation.">
    <available property="jdk1.8+" classname="java.util.function.Consumer"/>
    <fail unless="jdk1.8+"
          message="Must use Java 8 or later for creating the Javadocs"/>
    <tstamp>
      <!-- Used to ensure end-year is up to date -->
      <format property="THISYEAR" pattern="yyyy"/>
    </tstamp>

    <!-- JMeter Javadoc version (own variable is used so can be overridden independently) -->
    <property name="docversion" value="${jmeter.version}"/>

    <mkdir dir="${dest.docs.api}"/>
    <delete quiet="true">
      <fileset dir="${dest.docs.api}" includes="**/*.html"/>
    </delete>
    <echo level="info">Updating overview to ${docversion}</echo>
    <replaceregexp match="version [^\s]+"
                 encoding="${encoding}"
                 replace="version ${docversion}"
                 flags="g" byline="true">
      <fileset dir="${src.docs}" includes="overview.html" />
    </replaceregexp>
    <javadoc
      sourcepathref="srcpaths"
      overview="${src.docs}/overview.html"
      additionalparam="-breakiterator -notimestamp"
      destdir="${dest.docs.api}"
      encoding="${javadoc.encoding}"
      verbose="false"
      protected="yes"
      version="yes"
      doctitle="Apache JMeter API"
      windowtitle="Apache JMeter API"
      header="&lt;b&gt;Apache JMeter&lt;/b&gt;"
      bottom="Copyright &amp;#xA9; 1998-${THISYEAR} Apache Software Foundation. All Rights Reserved."
      packagenames="org.apache.jmeter.*,org.apache.jorphan.*">
      <classpath>
        <path refid="classpath"/>
        <path refid="logging.classpath"/>
      </classpath>
      <link href="http://docs.oracle.com/javase/8/docs/api/"/>
    </javadoc>
    <!-- No need for Javadoc patch (CVE-2013-1571) now we are using Java 8 minimum -->
  </target>

  <!--
    Run Doccheck: See http://java.sun.com/j2se/javadoc/doccheck/docs/DocCheck.html
    and http://java.sun.com/j2se/javadoc/doccheck/
    Download the doclet, and put the jar in lib/opt.
    Output is in reports/ directory
  -->
  <target name="docs-check">
    <javadoc sourcepathref="srcpaths"
             destdir="reports"
             docletpath="${lib.opt}/doccheck.jar"
             packagenames="org.apache.jmeter.*,org.apache.jorphan.*"
             excludepackagenames="org.apache.jmeter.util.keystore">
      <classpath refid="classpath"/>
      <doclet name="com.sun.tools.doclets.doccheck.DocCheck">
        <!--
            -execDepth: 1=org.* 2=org.apache.* 3+=org.apache.jmeter.*
            -evident does not seem to work
         -->
        <param name="-execDepth" value="3"/>
        <param name="-evident" value="4"/>
      </doclet>
    </javadoc>
  </target>

  <target name="docs-site" depends="init-docs" description="Generate browsable HTML documentation in web-site format.">
    <mkdir dir="${dest.docs}" />
    <!-- The extending pages are rather out of date (and not linked from elsewhere) -->
    <xslt style="xdocs/stylesheets/website-style.xsl" basedir="${src.docs}" destdir="${dest.docs}"
      force="${docs.force}" excludes="extending.xml" includes="*.xml">
      <param name="relative-path" expression="." />
      <param name="subdir" expression="" />
      <param name="year" expression="${year}" />
    </xslt>
    <xslt style="xdocs/stylesheets/website-style.xsl" basedir="${src.docs}/usermanual" destdir="${dest.docs}/usermanual"
      force="${docs.force}" includes="*.xml">
      <param name="relative-path" expression=".." />
      <param name="subdir" expression="usermanual" />
      <param name="year" expression="${year}" />
    </xslt>
    <xslt style="xdocs/stylesheets/website-style.xsl" basedir="${src.docs}/localising" destdir="${dest.docs}/localising"
      force="${docs.force}" includes="*.xml">
      <param name="relative-path" expression=".." />
      <param name="subdir" expression="usermanual" />
      <param name="year" expression="${year}" />
    </xslt>
    <copy todir="${dest.docs}/images" overwrite="${docs.force}">
      <fileset dir="${src.images}" />
    </copy>
    <copy todir="${dest.docs}/css" overwrite="${docs.force}">
      <fileset dir="${src.css}"/>
    </copy>
    <!--
    Note: it's vital that the Javadoc files are excluded from any fixes applied here.
    Any fixes to Javadoc files need to be done in the docs-api target only.
    Otherwise the output from the build will depend on which is done first.
    -->
    <echo level="info">Fixing EOL</echo>
    <fixcrlf encoding="utf-8" srcdir="${dest.docs}/" includes="**/*.html" excludes="api/**" fixlast="false"/>
    <echo level="info">Removing unnecessary &lt;/br> tags</echo>
    <replace encoding="utf-8" dir="${dest.docs}/" includes="**/*.html" excludes="api/**" token="&lt;/br>" value=""/>
    <copy todir="${dest.docs}/demos">
      <fileset dir="${src.demos}"/>
    </copy>
    <copy todir="${dest.docs}/usermanual">
      <fileset file="${src.docs}/usermanual/*.pdf"/>
    </copy>
    <copy todir="${dest.docs}/extending">
      <fileset file="${src.docs}/extending/jmeter_tutorial.pdf"/>
    </copy>
    <copy todir="${dest.docs}/">
      <fileset file="${src.docs}/download_jmeter.cgi"/>
    </copy>
  </target>

  <target name="docs-printable" depends="init-docs" if="AnakiaTask.present" description="Generate printable HTML documentation.">
    <taskdef name="anakia" classpathref="anakia.classpath" classname="org.apache.velocity.anakia.AnakiaTask"/>
    <!-- The extending pages are rather out of date (and not linked from elsewhere) -->
    <anakia basedir="${src.docs}" destdir="${dest.printable_docs}/" extension=".html" style="${eclipse.anakia}/xdocs/stylesheets/site_printable.vsl" projectFile="./stylesheets/printable_project.xml"
        excludes="**/stylesheets/** extending.xml extending/*.xml"
        includes="**/*.xml" lastModifiedCheck="${anakia.lastModifiedCheck}" velocityPropertiesFile="${src.docs}/velocity.properties"/>
    <echo level="info">Fixing EOL</echo>
    <fixcrlf encoding="utf-8" srcdir="${dest.printable_docs}/" includes="**/*.html" fixlast="false"/>
    <echo level="info">Removing unnecessary &lt;/br> tags</echo>
    <replace encoding="utf-8" dir="${dest.printable_docs}/" includes="**/*.html" token="&lt;/br>" value=""/>
    <!--
    Share images with non-printable version
    Means printable version won't work on web-site
    -->
    <echo level="info">Copying files</echo>
    <copy todir="${dest.docs}/css">
      <fileset dir="${src.css}"/>
    </copy>
    <copy todir="${dest.docs}/images">
      <fileset dir="${src.images}" />
    </copy>
    <copy todir="${dest.printable_docs}/demos">
      <fileset dir="${src.demos}"/>
    </copy>
    <copy todir="${dest.printable_docs}/usermanual">
        <fileset file="${src.docs}/usermanual/*.pdf"/>
    </copy>
    <copy todir="${dest.printable_docs}/extending">
      <fileset file="${src.docs}/extending/jmeter_tutorial.pdf"/>
    </copy>
  </target>

  <target name="test" depends="_test,_allbatchtests"
    description="Run tests (use -Djava.awt.headless=true on systems without graphic displays)"/>

  <target name="test-both" depends="test-headless,test-headed"/>

  <target name="test-headless" depends="compile-tests">
    <antcall target="_test">
      <param name="test.headless" value="true"/>
    </antcall>
  </target>

  <target name="test-headed" depends="compile-tests">
    <antcall target="_test">
      <param name="test.headless" value="false"/>
    </antcall>
  </target>

  <target name="batchtestserver" description="Run the batch test using client-server mode">
    <property name="batchtestserver.out" location="${basedir}/bin"/>
    <property name="batchtestserver.log" value="BatchTestServer.log"/>
    <!-- rmi_force_localhost is used by the Travis build -->
    <condition property="rmi_hostname_option" value="-Ddummy=true">
      <not><isset property="rmi_force_localhost"/></not>
    </condition>
    <condition property="rmi_hostname_option" value="-Djava.rmi.server.hostname=${computer.hostname}">
      <isset property="rmi_force_localhost"/>
    </condition>
    <condition property="jacoco_params" value="${jacocoagent}" else="-Djacoco_dummy=">
      <isset property="jacocoagent"/>
    </condition>
    <tstamp>
      <!-- Use variable port to help avoid clashes on CI servers -->
      <format property="rmi_port" pattern="2SSS"/>
    </tstamp>
    <parallel>
      <daemons>
        <java taskname="server" classname="org.apache.jmeter.NewDriver" fork="yes" dir="${batchtestserver.out}">
          <classpath>
            <fileset dir="${dest.jar.jmeter}" includes="*.jar"/>
            <fileset dir="${dest.jar}" includes="*.jar"/>
            <path refid="classpath"/>
            <path refid="logging.classpath"/>
          </classpath>
          <jvmarg value="${jacoco_params}batchtest:daemon:java(server)"/>
          <jvmarg value="-Xms64m"/>
          <jvmarg value="-Xmx128m"/>
          <jvmarg value="-Xss256k"/>
          <jvmarg value="-XX:MaxMetaspaceSize=128m"/>
          <sysproperty key="java.awt.headless" value="true"/>
          <!-- Bug 59723 -->
          <!-- pick up default properties -->
          <arg value="-pjmeter.properties"/>
          <!-- reset other parameters -->
          <arg value="-qtestfiles/jmeter-batch.properties"/>
          <arg value="-i"/>
          <arg value="testfiles/log4j2-batch.xml"/>
          <arg value="-j"/>
          <arg value="${batchtestserver.out}/${batchtestserver.log}"/>
          <arg value="-Dserver_port=${rmi_port}"/>
          <arg value="-s"/>
          <arg value="-Jserver.exitaftertest=true"/>
          <arg value="${rmi_hostname_option}"/>
        </java>
      </daemons>
      <sequential>
        <!-- Increase as necessary to ensure server has time to start -->
        <sleep seconds="2"/>
        <antcall target="batchtest">
          <param name="remote" value="-R${computer.hostname}:${rmi_port}"/>
          <param name="taskname" value="client"/>
          <!-- Default the test name so we can override with a parameter -->
        </antcall>
      </sequential>
    </parallel>
    <!-- Show the log file -->
    <concat>
      <filelist dir="${batchtestserver.out}" files="${batchtestserver.log}" />
    </concat>

    <local         name="BatchTestLocalServer.len"/>
    <condition property="BatchTestLocalServer.len">
      <length file="${batchtestserver.out}/${batchtestserver.log}" when="equal" length="0" />
    </condition>
    <fail unless="BatchTestLocalServer.len">
        Error detected in server log file. See above.
    </fail>

    <delete>
      <fileset dir="${batchtestserver.out}">
        <include name="${batchtestserver.log}"/>
      </fileset>
     </delete>
  </target>

  <target name="batchtest" description="Run the batch test and compare output files" unless="${skip.batchtest}">

    <!-- will be overwritten by antcall parameters -->
    <property name="taskname" value="jmeter"/>
    <property name="remote" value="-X"/>
    <property name="batchtest.ignoreErrorLogs" value="false" />
    <property name="batchtest.inp" location="${basedir}/bin/testfiles"/>
    <property name="batchtest.out" location="${basedir}/bin"/>
    <property name="batchtest.name" value="BatchTestLocal"/>
    <property name="batchtest.jmx" value="${batchtest.name}.jmx"/>
    <!--
         Allow variable to be set on the command line
         Cannot omit value because that causes a warning message
     -->
    <property name="batchtest.variable" value="dummy"/>
    <property name="batchtest.value" value="dummy"/>

    <!-- Fix the EOL in case the file was derived from the "wrong" archive type -->
    <fixcrlf encoding="${encoding}" srcdir="${batchtest.inp}" includes="${batchtest.name}.csv"/>

    <echo level="info" message="Starting ${batchtest.name} with file ${batchtest.jmx} using ${remote} -J${batchtest.variable}=${batchtest.value}"/>

    <macrodef name="deleteworkfiles">
      <sequential>
        <delete>
          <fileset dir="${batchtest.out}">
            <include name="${batchtest.name}.csv"/>
            <include name="${batchtest.name}.xml"/>
            <include name="${batchtest.name}.log"/>
            <include name="${batchtest.name}.jtl"/>
            <!-- Allow for optional error files -->
            <include name="${batchtest.name}.err"/>
          </fileset>
        </delete>
      </sequential>
    </macrodef>

    <macrodef name="checkfile">
      <attribute name="type" default=""/>
      <attribute name="file"/>
      <sequential>
        <local name="found"/>
        <!--echo>Looking for @{file}</echo-->
        <available property="found" file="@{file}"/>
        <fail message="Cannot find @{type} file @{file}" unless="found"/>
      </sequential>
    </macrodef>

    <checkfile type="input" file="${batchtest.inp}${file.separator}${batchtest.name}.csv"/>
    <checkfile type="input" file="${batchtest.inp}${file.separator}${batchtest.name}.xml"/>

    <deleteworkfiles/>

    <condition property="jacoco_params" value="${jacocoagent}" else="-Djacoco_dummy=">
      <isset property="jacocoagent"/>
    </condition>

    <java taskname="${taskname}" classname="org.apache.jmeter.NewDriver" fork="yes" dir="${basedir}/bin">
      <classpath>
        <fileset dir="${dest.jar.jmeter}" includes="*.jar"/>
        <fileset dir="${dest.jar}" includes="*.jar"/>
        <path refid="classpath"/>
        <path refid="logging.classpath"/>
      </classpath>
      <jvmarg value="-Xms64m"/>
      <jvmarg value="-Xmx128m"/>
      <jvmarg value="-Xss256k"/>
      <jvmarg value="-XX:MaxMetaspaceSize=128m"/>
      <jvmarg value="${jacoco_params}batchtest:java(${taskname})"/>
      <jvmarg value="-Djava.rmi.server.hostname=${computer.hostname}" if:set="rmi_force_localhost"/>
      <!-- Detect if non-GUI runs OK headless by forcing it to try using non-headless mode -->
      <sysproperty key="user.language" value="en"/>
      <sysproperty key="user.region" value="US"/>
      <sysproperty key="java.awt.headless" value="false"/>
      <!-- Bug 59723 -->
      <!-- pick up default properties -->
      <arg value="-pjmeter.properties"/>
      <!-- reset other parameters -->
      <arg value="-qtestfiles/jmeter-batch.properties"/>
      <arg value="-n"/>
      <arg value="-ttestfiles/${batchtest.jmx}"/>
      <arg value="-i"/>
      <arg value="testfiles/log4j2-batch.xml"/>
      <arg value="-j"/>
      <arg value="${batchtest.name}.log"/>
      <arg value="-l"/>
      <arg value="${batchtest.name}.jtl"/>
      <arg value="${remote}"/>
      <!-- Check properties can be passed to local/remote tests -->
      <arg value="-Jmodule=Module"/>
      <arg value="-Gmodule=Module"/>
      <!-- Check property can be used for filenames in local/remote tests (no need to defined as -G) -->
      <arg value="-JCSVFILE=${batchtest.name}.csv"/>
      <arg value="-J${batchtest.variable}=${batchtest.value}"/>
    </java>

    <!-- Show the log file -->
    <concat>
      <filelist dir="${batchtest.out}" files="${batchtest.name}.log" />
    </concat>

    <checkfile type="output" file="${batchtest.out}${file.separator}${batchtest.name}.csv"/>
    <checkfile type="output" file="${batchtest.out}${file.separator}${batchtest.name}.xml"/>
    <checkfile type="output" file="${batchtest.out}${file.separator}${batchtest.name}.jtl"/>

    <local         name="BatchTestLocal.csv.OK"/>
    <local         name="file1.csv"/>
    <local         name="file2.csv"/>

    <loadfile property="file1.csv" srcFile="${batchtest.inp}/${batchtest.name}.csv"/>
    <loadfile property="file2.csv" srcFile="${batchtest.out}/${batchtest.name}.csv"/>
    <condition property="BatchTestLocal.csv.OK">
      <filesmatch file1="${batchtest.inp}/${batchtest.name}.csv" file2="${batchtest.out}/${batchtest.name}.csv"/>
    </condition>
    <fail unless="BatchTestLocal.csv.OK">
        CSV Files are not identical.
        ${batchtest.inp}${file.separator}${batchtest.name}.csv
        ${file1.csv}
        ${batchtest.out}${file.separator}${batchtest.name}.csv
        ${file2.csv}
    </fail>

    <local         name="BatchTestLocal.xml.OK"/>
    <local         name="file1.xml"/>
    <local         name="file2.xml"/>
    <loadfile property="file1.xml" srcFile="${batchtest.inp}/${batchtest.name}.xml"/>
    <loadfile property="file2.xml" srcFile="${batchtest.out}/${batchtest.name}.xml"/>
    <condition property="BatchTestLocal.xml.OK">
     <filesmatch file1="${batchtest.inp}/${batchtest.name}.xml" file2="${batchtest.out}/${batchtest.name}.xml"/>
    </condition>
    <fail unless="BatchTestLocal.xml.OK">
        XML Files are not identical.
        ${batchtest.inp}${file.separator}${batchtest.name}.xml
        ${file1.xml}
        ${batchtest.out}${file.separator}${batchtest.name}.xml
        ${file2.xml}
    </fail>

    <echo level="info">${batchtest.name} output files compared OK</echo>

    <local         name="BatchTestLocal.len"/>
    <!-- We define "BatchTestLocal.len" property only if log file is empty
      or  batchtest.ignoreErrorLogs is false
    -->
    <condition property="BatchTestLocal.len">
        <or>
          <length file="${batchtest.out}/${batchtest.name}.log" when="equal" length="0" />
          <equals arg1="${batchtest.ignoreErrorLogs}" arg2="true" casesensitive="true"/>
        </or>
    </condition>

    <fail unless="BatchTestLocal.len">
        Error detected in log file. See above.
    </fail>

    <deleteworkfiles/>

  </target>

  <!-- Additional test scripts -->
  <target name="batch_scripts">
      <antcall target="batchtest">
        <param name="batchtest.name" value="BUG_62847"/>
        <param name="batchtest.jmx" value="BUG_62847.jmx"/>
      </antcall>
      
      <antcall target="batchtest">
        <param name="batchtest.name" value="TestResultStatusAction"/>
        <param name="batchtest.jmx" value="TestResultStatusAction.jmx"/>
      </antcall>

      <antcall target="batchtest">
        <param name="batchtest.name" value="TestRedirectionPolicies"/>
        <param name="batchtest.jmx" value="TestRedirectionPolicies.jmx"/>
      </antcall>
      
      <antcall target="batchtest">
      <param name="batchtest.name" value="HTMLParserTestFile_2"/>
      <param name="batchtest.jmx" value="HTMLParserTestFile_2.jmx"/>
    </antcall>
  <!-- Disable Test which seems wrong -->
  <!--
    <antcall target="batchtest">
      Using the same module controller name in command line mode causes NPE
      <param name="batchtest.name" value="Bug47165"/>
      <param name="batchtest.jmx" value="Bug47165.jmx"/>
    </antcall>
  -->

    <antcall target="batchtest">
      <!-- variable in IPSource failed HTTP request if "Concurrent Pool Size" is enabled -->
      <!-- N.B. requires access to jmeter.apache.org -->
      <param name="batchtest.name" value="Bug52310"/>
      <param name="batchtest.jmx" value="Bug52310.jmx"/>
      <param name="skip.batchtest" value="${skip.bug52310}" />
    </antcall>

    <antcall target="batchtest">
      <!-- Flow Control Action: Break Loop and Start Next Iteration of Loop -->
      <param name="batchtest.name" value="Bug62239"/>
      <param name="batchtest.jmx" value="Bug62239.jmx"/>
    </antcall>

    <antcall target="batchtest">
      <!-- Option Start Next Loop in Thread Group does not mark parent Transaction Sampler in error when an error occurs -->
      <param name="batchtest.name" value="Bug52968"/>
      <param name="batchtest.jmx" value="Bug52968.jmx"/>
    </antcall>

    <antcall target="batchtest">
      <!-- IncludeController : NullPointerException loading script in non-GUI mode if Includers use same element name -->
      <param name="batchtest.name" value="Bug50898"/>
      <param name="batchtest.jmx" value="Bug50898.jmx"/>
    </antcall>

    <antcall target="batchtest">
      <!-- Foreach works incorrectly with indexes on subsequent iterations -->
      <param name="batchtest.name" value="Bug56243"/>
      <param name="batchtest.jmx" value="Bug56243.jmx"/>
    </antcall>

    <antcall target="batchtest">
      <!-- ArrayIndexOutOfBoundsException if "sample_variable" is set in client but not server -->
      <!-- This is unaffected by the bug; it just checks the script works OK in local mode -->
      <param name="batchtest.name" value="Bug54685"/>
      <param name="batchtest.jmx" value="Bug54685.jmx"/>
      <param name="batchtest.variable" value="sample_variables"/>
      <param name="batchtest.value" value="REFERENCE,JSESSIONID"/>
    </antcall>

    <antcall target="batchtest">
      <!--   StackOverflowError with ModuleController in Non-GUI mode if its name is the same as the target node -->
      <param name="batchtest.name" value="Bug55375"/>
      <param name="batchtest.jmx" value="Bug55375.jmx"/>
    </antcall>

    <antcall target="batchtestserver">
      <!-- ArrayIndexOutOfBoundsException if "sample_variable" is set in client but not server -->
      <!-- This is the actual test -->
      <param name="batchtest.name" value="Bug54685"/>
      <param name="batchtest.jmx" value="Bug54685.jmx"/>
      <param name="batchtest.variable" value="sample_variables"/>
      <param name="batchtest.value" value="REFERENCE,JSESSIONID"/>
    </antcall>

    <antcall target="batchtest">
      <param name="batchtest.name" value="Bug56811"/>
      <param name="batchtest.jmx" value="Bug56811.jmx"/>
    </antcall>

    <antcall target="batchtest">
      <param name="batchtest.name" value="TEST_HTTPS"/>
      <param name="batchtest.jmx" value="TEST_HTTPS.jmx"/>
      <param name="skip.batchtest" value="${skip.test_https}" />
    </antcall>

    <antcall target="batchtest">
      <param name="batchtest.name" value="TestCookieManager"/>
      <param name="batchtest.jmx" value="TestCookieManager.jmx"/>
    </antcall>

    <antcall target="batchtest">
      <param name="batchtest.name" value="TCP_TESTS"/>
      <param name="batchtest.jmx" value="TCP_TESTS.jmx"/>
      <param name="batchtest.ignoreErrorLogs" value="true" />
    </antcall>

    <antcall target="batchtest">
      <param name="batchtest.name" value="JDBC_TESTS"/>
      <param name="batchtest.jmx" value="JDBC_TESTS.jmx"/>
      <param name="batchtest.ignoreErrorLogs" value="true" />
    </antcall>

    <antcall target="batchtest">
      <param name="batchtest.name" value="JMS_TESTS"/>
      <param name="batchtest.jmx" value="JMS_TESTS.jmx"/>
      <param name="batchtest.ignoreErrorLogs" value="true" />
    </antcall>

    <antcall target="batchtest">
      <param name="batchtest.name" value="OS_TESTS"/>
      <param name="batchtest.jmx" value="OS_TESTS.jmx"/>
    </antcall>

    <antcall target="batchtest">
      <param name="batchtest.name" value="FTP_TESTS"/>
      <param name="batchtest.jmx" value="FTP_TESTS.jmx"/>
      <param name="batchtest.ignoreErrorLogs" value="true" />
    </antcall>

    <antcall target="batchtest">
      <param name="batchtest.name" value="Bug60607"/>
      <param name="batchtest.jmx" value="Bug60607.jmx"/>
      <param name="skip.batchtest" value="${skip.bug60607}" />
    </antcall>

    <antcall target="batchtest">
      <param name="batchtest.name" value="SlowCharsFeature_HttpClient4"/>
      <param name="batchtest.jmx" value="SlowCharsFeature.jmx"/>
      <param name="skip.batchtest" value="${skip.batchtest_SlowCharsFeature}" />
    </antcall>

    <antcall target="batchtest">
      <param name="batchtest.name" value="SlowCharsFeature_Java"/>
      <param name="batchtest.jmx" value="SlowCharsFeature.jmx"/>
      <param name="batchtest.variable" value="jmeter.httpsampler"/>
      <param name="batchtest.value" value="Java"/>
      <param name="skip.batchtest" value="${skip.batchtest_SlowCharsFeature}" />
    </antcall>

    <antcall target="batchtest">
      <param name="batchtest.name" value="TestKeepAlive"/>
      <param name="batchtest.jmx" value="TestKeepAlive.jmx"/>
      <param name="skip.batchtest" value="${skip.batchtest_TestKeepAlive}" />
    </antcall>

    <antcall target="batchtest">
       <param name="batchtest.name" value="ResponseDecompression"/>
       <param name="batchtest.jmx" value="ResponseDecompression.jmx"/>
       <param name="skip.batchtest" value="${skip.batchtest_ResponseDecompression}" />
    </antcall>

    <antcall target="batchtest">
      <param name="batchtest.name" value="TestHeaderManager"/>
      <param name="batchtest.jmx" value="TestHeaderManager.jmx"/>
      <param name="batchtest.variable" value="jmeter.httpsampler"/>
      <param name="batchtest.value" value="HttpClient4"/>
    </antcall>

    <antcall target="batchtest">
      <param name="batchtest.name" value="TestHeaderManager"/>
      <param name="batchtest.jmx" value="TestHeaderManager.jmx"/>
      <param name="batchtest.variable" value="jmeter.httpsampler"/>
      <param name="batchtest.value" value="Java"/>
    </antcall>

    <antcall target="batchtest">
      <param name="batchtest.name" value="TEST_HTTP_HttpClient4"/>
      <param name="batchtest.jmx" value="TEST_HTTP.jmx"/>
      <param name="batchtest.variable" value="jmeter.httpsampler"/>
      <param name="batchtest.value" value="HttpClient4"/>
      <param name="skip.batchtest" value="${skip.test_http}" />
    </antcall>

    <antcall target="batchtest">
      <param name="batchtest.name" value="TEST_HTTP_Java"/>
      <param name="batchtest.jmx" value="TEST_HTTP.jmx"/>
      <param name="batchtest.variable" value="jmeter.httpsampler"/>
      <param name="batchtest.value" value="Java"/>
      <!-- This test contains a Redirection loop that leads to an error -->
      <param name="batchtest.ignoreErrorLogs" value="true" />
      <param name="skip.batchtest" value="${skip.test_http}" />
    </antcall>

    <antcall target="batchtest">
      <param name="batchtest.name" value="TestSchedulerWithTimer"/>
      <param name="batchtest.jmx" value="TestSchedulerWithTimer.jmx"/>
    </antcall>
      
      <antcall target="batchtest">
        <param name="batchtest.name" value="Http4ImplPreemptiveBasicAuth"/>
        <param name="batchtest.jmx" value="Http4ImplPreemptiveBasicAuth.jmx"/>
        <param name="batchtest.variable" value="jmeter.httpsampler"/>
        <param name="batchtest.value" value="Java"/>
        <param name="skip.batchtest" value="${skip.batchtest_Http4ImplPreemptiveBasicAuth}" />
      </antcall>
      <antcall target="batchtest">
        <param name="batchtest.name" value="Http4ImplPreemptiveBasicAuth"/>
        <param name="batchtest.jmx" value="Http4ImplPreemptiveBasicAuth.jmx"/>
        <param name="skip.batchtest" value="${skip.batchtest_Http4ImplPreemptiveBasicAuth}" />
      </antcall>
      <antcall target="batchtest">
        <param name="batchtest.name" value="Http4ImplDigestAuth"/>
        <param name="batchtest.jmx" value="Http4ImplDigestAuth.jmx"/>
      </antcall>
  </target>

  <!-- Run all batch tests; used by test target -->
  <target name="_allbatchtests" depends="batchtest,batchtestserver,batch_scripts">
  </target>

   <!-- Generic test target, not intended to be called directly -->
   <target name="_test" depends="compile-tests,package">
   <!--
   The property java.awt.headless is not automatically passed on,
   because the tests are run in a separate JVM from the build.

   It is assumed that Gump sets java.awt.headless if required.

   Set test.headless from the java.awt property, if that
   is defined, otherwise it us set to "".
   N.B. if test.headless is already set, it will not be changed
   This allows the property to be over-ridden by test-headless etc.
   -->
    <condition property="test.headless" value="${java.awt.headless}">
      <isset property="java.awt.headless"/>
    </condition>
     <!-- make sure test.headless is set to something -->
     <condition property="test.headless" value="">
      <not><isset property="java.awt.headless"/></not>
     </condition>

   <!-- set build.test.gump to build.test if not already set -->
    <condition property="build.test.gump" value="${build.test}">
      <not><isset property="build.test.gump"/></not>
    </condition>
    <echo level="info">
   gump.run = ${gump.run}
   java.awt.headless = ${java.awt.headless}
   test.headless = ${test.headless}
   user.dir = ${user.dir}
   basedir = ${basedir}
   test dir = ${build.test}
   test dir gump = ${build.test.gump}
   testsaveservice.saveout = ${testsaveservice.saveout}
   test.encoding = ${test.encoding}
    </echo>
    <delete quiet="true">
      <fileset dir="${basedir}/bin/testfiles" includes="*.jmx.out"/>
    </delete>
    <condition property="jacoco_params" value="${jacocoagent}" else="-Djacoco_dummy=">
      <isset property="jacocoagent"/>
    </condition>
    <!-- fork="yes" is required or dir attribute is ignored -->
    <java classname="org.apache.jorphan.test.AllTests" fork="yes" failonerror="true" dir="${basedir}/bin">
      <classpath>
        <fileset dir="${dest.jar.jmeter}" includes="ApacheJMeter.jar"/>
        <fileset dir="${dest.jar}" includes="*.jar"/>
        <pathelement location="${build.test}"/>
        <pathelement location="${build.test-res}"/>
        <path refid="classpath"/>
        <path refid="logging.classpath"/>
      </classpath>
      <jvmarg value="-Xss256k"/>
      <jvmarg value="-XX:MaxMetaspaceSize=256m"/>
      <jvmarg value="-server"/>
      <jvmarg value="${jacoco_params}_test:java"/>
      <jvmarg value="-Dfile.encoding=${test.encoding}"/>
      <jvmarg value="-Djava.rmi.server.hostname=${computer.hostname}" if:set="rmi_force_localhost"/>
      <sysproperty key="java.awt.headless" value="${test.headless}"/>
      <sysproperty key="testsaveservice.saveout" value="${testsaveservice.saveout}" />
      <sysproperty key="gump.run" value="${gump.run}" />
      <sysproperty key="log4j.configurationFile" value="${basedir}/bin/log4j2.xml" />
      <sysproperty key="skip.test_TestDNSCacheManager.testWithCustomResolverAnd1Server"
        value="${skip.test_TestDNSCacheManager.testWithCustomResolverAnd1Server}" />
      <arg value="${build.test}"/>
      <arg value="${basedir}/bin/jmeter.properties"/>
      <arg value="org.apache.jmeter.util.JMeterUtils"/>
    </java>
  </target>

  <!--
    In order to run JUnit, both junit.jar and optional.jar need to be on the Ant classpath
    optional.jar is normally found in ANT_HOME/lib
  -->
  <target name="junit"  depends="compile-tests"
    description="Run individual JUnit test (-Dtest.case=org.apache.jorphan.test.AllTests) (-Dtest.format=plain) (-Dtest.showoutput=true)">
    <mkdir dir="reports"/>
    <property name="test.format" value="plain"/>
    <property name="test.case" value="org.apache.jorphan.test.AllTests"/>
    <property name="test.showoutput" value="false"/>
    <condition property="jacoco_params" value="${jacocoagent}" else="-Djacoco_dummy=">
      <isset property="jacocoagent"/>
    </condition>
    <junit fork="true"
           dir="${basedir}/bin"
           showoutput="${test.showoutput}"
           printsummary="on">
      <formatter type="${test.format}" usefile="yes"/>
      <formatter type="xml"/>
      <jvmarg value="${jacoco_params}run_gui:junit"/>
      <jvmarg value="-Dfile.encoding=${test.encoding}"/>
      <!-- Allow headless to be passed in -->
      <jvmarg value="-Djava.awt.headless=${java.awt.headless}"/>
      <classpath>
        <fileset dir="${dest.jar}" includes="*.jar"/>
        <pathelement location="${build.test}"/>
        <path refid="classpath"/>
        <path refid="logging.classpath"/>
      </classpath>
      <test name="${test.case}" todir="reports"/>
    </junit>
  </target>

  <target name="complete-junit"  depends="compile-tests"
    description="Run all JUnit tests (-Dtest.format=plain) (-Dtest.showoutput=true)"
    xmlns:jacoco="antlib:org.jacoco.ant">
  <mkdir dir="reports"/>
  <property name="test.format" value="plain"/>
  <property name="test.case" value="org.apache.jorphan.test.AllTests"/>
  <property name="test.showoutput" value="false"/>
  <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
    <classpath refid="sonar.classpath" />
  </taskdef>
  <jacoco:coverage destfile="reports/jacoco.exec">
  <junit fork="true"
      forkmode="once"
      dir="${basedir}/bin"
      showoutput="${test.showoutput}"
      printsummary="on">
    <formatter type="${test.format}" usefile="yes"/>
    <formatter type="xml"/>
    <jvmarg value="-Dfile.encoding=${test.encoding}"/>
    <!-- Allow headless to be passed in -->
    <jvmarg value="-Djava.awt.headless=${java.awt.headless}"/>
    <sysproperty key="log4j.configurationFile" value="${basedir}/bin/log4j2.xml" />
    <classpath>
      <fileset dir="${dest.jar}" includes="*.jar"/>
      <pathelement location="${build.test}"/>
      <pathelement location="${build.test-res}"/>
      <path refid="classpath"/>
      <path refid="logging.classpath"/>
    </classpath>
    <batchtest todir="reports" skipNonTests="true">
        <fileset dir="${build.test}">
            <include name="**/*Spec.class" />
        </fileset>
        <fileset dir="${src.test}">
            <include name="**/*Test*.java" />
            <exclude name="**/AllTests.java" />
        </fileset>
    </batchtest>
  </junit>
  </jacoco:coverage>
  </target>

  <!-- Utility target to collate reports -->
  <target name="junitreport">
    <mkdir dir="reports"/>
    <junitreport todir="reports">
      <fileset dir="reports">
        <include name="TEST-*.xml"/>
      </fileset>
      <report format="frames" todir="reports"/>
    </junitreport>
  </target>

  <target name="generator_jar" depends="compile-tests" description="Create the test tree generator jar">
    <jar jarfile="${dest.jar}/ApacheJMeter_generator.jar"
         manifest="${build.dir}/MANIFEST_BIN.MF">
      <zipfileset file="${resources.meta-inf}/default.notice"
         fullpath="META-INF/NOTICE" />
      <zipfileset file="${resources.meta-inf}/default.license"
         fullpath="META-INF/LICENSE" />
      <fileset dir="${build.test}" includes="**/GenerateTreeGui*.class"/>
    </jar>
  </target>

  <target name="svnCheck" description="Use SVN to get the current revision" unless="disable-svnCheck">
    <exec executable="svn" logerror="true" outputproperty="svn.exec.result" failonerror="true" failifexecutionfails="true">
      <arg line="info"/>
    </exec>
    <loadresource property="svn.revision">
      <string value="${svn.exec.result}"/>
      <filterchain>
        <linecontains>
          <contains value="Last Changed Rev: "/>
        </linecontains>
        <tokenfilter>
            <!-- Remove all but the revision number -->
            <replaceregex pattern=".*: " replace=""/>
        </tokenfilter>
        <striplinebreaks/>
      </filterchain>
    </loadresource>
    <echo level="info" message="svn.revision=${svn.revision}"/>
  </target>

  <!-- Macro is needed to be able to perform indirect evaluation of property names -->
  <macrodef name="process_jarfile">
    <attribute name="jarname"/>
    <attribute name="dest.dir" default="${lib.dir}"/>
    <sequential>
      <!-- Call all possible targets; these are only executed if the appropriate property is set -->
      <antcall target="_check_exists">
        <param name="file" value="@{dest.dir}/${@{jarname}.jar}"/>
        <param name="loc" value="${@{jarname}.loc}"/>
        <param name="jar" value="${@{jarname}.jar}"/>
        <param name="path" value="@{dest.dir}"/>
        <param name="sha512"  value="${@{jarname}.sha512}"/>
        <param name="_checkSHA512" value="true"/>
      </antcall>
      <antcall target="_check_jarfile">
        <param name="loc" value="${@{jarname}.loc}"/>
        <param name="jar" value="${@{jarname}.jar}"/>
        <param name="path" value="@{dest.dir}"/>
        <param name="sha512"  value="${@{jarname}.sha512}"/>
        <param name="_checkSHA512" value="true"/>
        <param name="zip" value="${@{jarname}.zip}"/>
        <param name="ent" value="${@{jarname}.ent}"/>
        <param name="zipprop" value="@{jarname}.zip"/>
      </antcall>
    </sequential>
  </macrodef>

  <!-- Check if jarfile exists, and set properties for calling zip or jar download -->
  <target name="_check_jarfile" if="_get_file">
    <!-- Check if file exists -->
    <fail message="Error in build file or calling sequence" if="file.exists"/>
    <echo level="info">Checking ${jar}</echo>
    <available file="${path}/${jar}" property="file.exists"/>
    <condition property="_get_zipfile">
      <isset property="${zipprop}"/>
    </condition>
    <condition property="_get_jarfile">
      <not>
        <isset property="${zipprop}"/>
      </not>
    </condition>
    <!-- Delete all but the desired version of the file -->
    <loadresource property="wildCard">
      <propertyresource name="jar"/>
      <filterchain>
        <tokenfilter>
          <filetokenizer/>
          <!-- Replace version with a wildcard. e.g, foo-1.2.3.jar or foo-1.2.3.RELEASE.jar to foo-*.jar -->
          <replaceregex pattern="-(\d+\.){2,}([A-Za-z]*)[-|\d]*?\.(jar|zip)" replace="-*\2"/>
        </tokenfilter>
      </filterchain>
    </loadresource>
    <echo level="info" message="Deleting ${wildCard} (excluding ${jar})"/>
    <delete verbose="true">
      <!-- Unfortunately commons-jexl jars don't have unique prefixes -->
      <fileset dir="${path}" includes="${wildCard}" excludes="${jar} commons-jexl-*"/>
    </delete>
    <!-- Emulate conditional execution; targets use if/unless to suppress execution -->
    <antcall target="_get_jarfile"/>
    <antcall target="_get_zipfile"/>
  </target>

  <!-- Get a zip file and unpack it -->
  <target name="_get_zipfile" if="_get_zipfile" unless="file.exists" depends="setproxy">
    <get src="${loc}/${zip}"
         dest="${build.dir}/${zip}"
         usetimestamp="true" ignoreerrors="false"/>
    <unzip dest="${build.dir}" src="${build.dir}/${zip}">
      <patternset>
        <include name="**/${ent}"/>
      </patternset>
      <!-- This requires Ant 1.7.0 or later -->
      <mapper type="flatten"/>
    </unzip>
    <antcall target="_checkSHA512">
      <param name="file" value="${ent}"/>
      <param name="path" value="${build.dir}"/>
      <param name="sha512"  value="${sha512}"/>
    </antcall>
    <move preservelastmodified="true" overwrite="true"
          file="${build.dir}/${ent}" tofile="${path}/${jar}" verbose="true"/>
  </target>

  <!-- Download a jar file and check its hash; if correct, move to correct directory -->
  <target name="_get_jarfile" if="_get_jarfile" unless="file.exists" depends="setproxy">
    <echo message="Fetching: ${path}/${jar}" level="info"/>
    <get src="${loc}/${jar}"
         dest="${build.dir}/${jar}"
         usetimestamp="false" ignoreerrors="false"/>
    <antcall target="_checkSHA512">
      <param name="file" value="${jar}"/>
      <param name="path" value="${build.dir}"/>
      <param name="sha512"  value="${sha512}"/>
    </antcall>
    <move preservelastmodified="true" overwrite="true"
          file="${build.dir}/${jar}" tofile="${path}/${jar}" verbose="true"/>
  </target>

  <!-- Ant subroutine, required to localise SHA512OK property -->
  <target name="_checkSHA512" if="_checkSHA512">
    <!--
    @param path - location of file
    @param file - file name
    -->
    <checksum algorithm="SHA-512" file="${path}/${file}" property="SHA512"/>
    <condition property="SHA512OK">
      <equals arg1="${SHA512}" arg2="${sha512}" casesensitive="false"/>
    </condition>
    <fail unless="SHA512OK">Bad Checksum: for ${file}
        expected ${sha512}
        actual   ${SHA512}</fail>
    <echo level="info" message="Checksum OK: ${file}"/>
  </target>

  <!--
    Generic target to process all external jars.
    The "process_jarfile" macro resolves the properties that begin with the jarname
    and calls all the possible targets. The targets use "if" and "unless" to provide
    conditional execution (it would be a lot easier if antcall supported if/unless).
  -->
  <target name="_process_all_jars">
    <process_jarfile jarname="accessors-smart"/>
    <process_jarfile jarname="apache-bsf"/>
    <process_jarfile jarname="asm"/>
    <process_jarfile jarname="bcmail" dest.dir="${lib.api}"/>
    <process_jarfile jarname="bcprov" dest.dir="${lib.api}"/>
    <process_jarfile jarname="bcpkix" dest.dir="${lib.api}"/>
    <process_jarfile jarname="beanshell"/>
    <process_jarfile jarname="dec"/>
    <process_jarfile jarname="caffeine"/>
    <process_jarfile jarname="commons-codec"/>
    <process_jarfile jarname="commons-collections"/>
    <process_jarfile jarname="commons-dbcp2"/>
    <process_jarfile jarname="commons-io"/>
    <process_jarfile jarname="commons-jexl2"/>
    <process_jarfile jarname="commons-jexl3"/>
    <process_jarfile jarname="commons-lang3"/>
    <process_jarfile jarname="commons-math3"/>
    <process_jarfile jarname="commons-net"/>
    <process_jarfile jarname="commons-pool2"/>
    <process_jarfile jarname="commons-text"/>
    <process_jarfile jarname="darcula"/>
    <process_jarfile jarname="dnsjava"/>
    <process_jarfile jarname="freemarker"/>
    <process_jarfile jarname="groovy-all"/>
    <process_jarfile jarname="hamcrest-core"/>
    <process_jarfile jarname="hamcrest-date"/>
    <process_jarfile jarname="httpclient"/>
    <process_jarfile jarname="httpasyncclient"/>
    <process_jarfile jarname="httpcore"/>
    <process_jarfile jarname="httpcore-nio"/>
    <process_jarfile jarname="httpmime"/>
    <process_jarfile jarname="jakarta-oro"/>
    <process_jarfile jarname="jackson-annotations"/>
    <process_jarfile jarname="jackson-core"/>
    <process_jarfile jarname="jackson-databind"/>
    <process_jarfile jarname="javamail"/>
    <process_jarfile jarname="jcharts"/>
    <process_jarfile jarname="jdom" dest.dir="${lib.doc}"/>
    <process_jarfile jarname="jms"/>
    <process_jarfile jarname="rhino"/>
    <process_jarfile jarname="javax.activation"/>
    <process_jarfile jarname="javax.activation-api"/>
    <process_jarfile jarname="jodd-core"/>
    <process_jarfile jarname="jodd-lagarto"/>
    <process_jarfile jarname="jodd-log"/>
    <process_jarfile jarname="jodd-props"/>
    <process_jarfile jarname="json-path"/>
    <process_jarfile jarname="json-smart"/>
    <process_jarfile jarname="jsoup"/>
    <process_jarfile jarname="junit"/>
    <process_jarfile jarname="mongo-java-driver"/>
    <process_jarfile jarname="ph-css" />
    <process_jarfile jarname="ph-commons" />
    <process_jarfile jarname="rsyntaxtextarea"/>
    <process_jarfile jarname="serializer"/>
    <process_jarfile jarname="slf4j-api"/>
    <process_jarfile jarname="jcl-over-slf4j"/>
    <process_jarfile jarname="log4j-api"/>
    <process_jarfile jarname="log4j-1.2-api"/>
    <process_jarfile jarname="log4j-core"/>
    <process_jarfile jarname="log4j-slf4j-impl"/>
    <process_jarfile jarname="spock-core"/>
    <process_jarfile jarname="cglib-nodep"/>
    <process_jarfile jarname="objenesis"/>
    <process_jarfile jarname="jtidy"/>
    <process_jarfile jarname="tika-core"/>
    <process_jarfile jarname="tika-parsers"/>
    <process_jarfile jarname="velocity"   dest.dir="${lib.doc}"/>
    <process_jarfile jarname="commons-lang" dest.dir="${lib.doc}"/>
    <process_jarfile jarname="xalan"/>
    <process_jarfile jarname="Saxon-HE"/>
    <process_jarfile jarname="xerces"/>
    <process_jarfile jarname="xml-apis"/>
    <process_jarfile jarname="xmlgraphics-commons"/>
    <process_jarfile jarname="xmlpull"/>
    <process_jarfile jarname="xpp3"/>
    <process_jarfile jarname="xstream"/>
    <process_jarfile jarname="hsqldb" dest.dir="${lib.coverage}" />
    <process_jarfile jarname="activemq-all" dest.dir="${lib.coverage}" />
    <process_jarfile jarname="mina-core" dest.dir="${lib.coverage}" />
    <process_jarfile jarname="ftplet-api" dest.dir="${lib.coverage}" />
    <process_jarfile jarname="ftpserver-core" dest.dir="${lib.coverage}" />
    <process_jarfile jarname="jacocoant" dest.dir="${lib.coverage}" />
    <process_jarfile jarname="sonarqube-ant-task" dest.dir="${lib.coverage}" />
  </target>

  <target name="_process_doc_jars">
    <process_jarfile jarname="commons-collections"/>
    <process_jarfile jarname="commons-lang"   dest.dir="${lib.doc}"/>
    <process_jarfile jarname="jdom"           dest.dir="${lib.doc}"/>
    <process_jarfile jarname="velocity"   dest.dir="${lib.doc}"/>
  </target>

  <target name="_process_checkstyle_jars">
    <process_jarfile jarname="checkstyle-all"    dest.dir="${lib.opt}"/>
  </target>

  <target name="_process_rat_jars">
    <process_jarfile jarname="rat"        dest.dir="${lib.opt}"/>
    <process_jarfile jarname="rat-tasks"  dest.dir="${lib.opt}"/>
  </target>

  <!-- Update a jar (clean, download, package in one shot.-->
  <target name="update_jar" depends="clean, download_jars, package">
  </target>


  <!-- Download all missing jars.-->
  <target name="download_jars" description="Download any missing jar files">
    <!-- build.dir may be needed as a temporary work area -->
    <mkdir dir="${build.dir}" />
    <!-- The directories must exist otherwise the build fails when deleting previous versions -->
    <mkdir dir="${lib.api}" />
    <mkdir dir="${lib.doc}" />
    <delete verbose="true">
      <!-- bcprov jars no longer have the same prefix so the wildcard delete does not work; drop any old ones -->
      <fileset dir="${lib.api}" includes="bcmail-jdk15-*.jar bcprov-jdk15-*.jar"/>
      <fileset dir="${lib.dir}" includes="ApacheJMeter_slf4j_logkit.jar bsh-2.0b5.jar" />
      <!-- tidy up unused Excalibur jars -->
      <fileset dir="${lib.dir}" includes="avalon-framework-4.1.4.jar excalibur-datasource-2.1.jar excalibur-instrument-1.0.jar excalibur-logger-1.1.jar excalibur-pool-api-2.1.jar excalibur-pool-impl-2.1.jar excalibur-pool-instrumented-2.1.jar"/>
      <!-- jdom jar has moved; drop the old one -->
      <fileset dir="${lib.dir}" includes="jdom-1.1.3.jar"/>
      <!-- Drop slf4j-nop implementation -->
      <fileset dir="${lib.dir}" includes="slf4j-nop-1.7.13.jar"/>
      <!-- tidy up unused commons-logging jar -->
      <fileset dir="${lib.dir}" includes="commons-logging-1.2.jar"/>
      <!-- tidy up unused commons-httpclient jar -->
      <fileset dir="${lib.dir}" includes="commons-httpclient-3.1.jar"/>
      <!-- tidy up unused htmlparser jars -->
      <fileset dir="${lib.dir}" includes="htmllexer-2.1.jar htmlparser-2.1.jar"/>
      <!-- tidy up unused logkit jars -->
      <fileset dir="${lib.dir}" includes="logkit-2.0.jar"/>
      <fileset dir="${lib.opt}" includes="org.jacoco.ant-*-nodeps.jar" excludes="${jacocoant.jar}"/>
      <!-- tidy up unused slf4j-ext jar -->
      <fileset dir="${lib.dir}" includes="slf4j-ext-1.7.25.jar" />
      <fileset dir="${lib.dir}" includes="spock-core-1.0-groovy-2.4.jar" />
    </delete>
    <antcall target="_process_all_jars">
        <param name="_get_file" value="true"/>
    </antcall>
  </target>

  <target name="download_doc_jars">
    <!-- build.dir may be needed as a temporary work area -->
    <mkdir dir="${build.dir}" />
    <antcall target="_process_doc_jars">
      <param name="_get_file" value="true"/>
    </antcall>
  </target>

  <target name="download_checkstyle">
    <!-- build.dir may be needed as a temporary work area -->
   <mkdir dir="${build.dir}" />
    <antcall target="_process_checkstyle_jars">
      <param name="_get_file" value="true"/>
    </antcall>
  </target>

  <target name="download_rat">
    <!-- build.dir may be needed as a temporary work area -->
   <mkdir dir="${build.dir}" />
    <antcall target="_process_rat_jars">
      <param name="_get_file" value="true"/>
    </antcall>
  </target>

  <target name="_coverage.prepare" >
     <available property="jacocoant.jar.available" file="${lib.coverage}/${jacocoant.jar}"/>
     <fail message="This task requires JaCoCo library, please run download_jars target to download it" unless="jacocoant.jar.available"/>
     <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
        <classpath path="${lib.coverage}/${jacocoant.jar}"/>
     </taskdef>
     <jacoco:agent property="jacocoagent"
                   destfile="reports/jacoco.exec"
                   includes="org.apache.jmeter.*:org.apache.jorphan.*:org.apache.commons.cli.avalon.*:org.sl4j.impl.StaticLoggerBinder:org.apache.http.impl.conn.*"
                   sessionid=""
     />
  </target>

  <target name="_coverage.report" depends="_coverage.prepare, init-version">
    <jacoco:report>
        <executiondata>
            <file file="reports/jacoco.exec"/>
        </executiondata>
        <structure name="JMeter ${jmeter.version} ${implementation.version}">
            <classfiles>
                <fileset dir="${build.components}"/>
                <fileset dir="${build.core}"/>
                <fileset dir="${build.functions}"/>
                <fileset dir="${build.jorphan}"/>
                <fileset dir="${build.junit}"/>
                <fileset dir="${build.ftp}"/>
                <fileset dir="${build.http}"/>
                <fileset dir="${build.java}"/>
                <fileset dir="${build.jdbc}"/>
                <fileset dir="${build.jms}"/>
                <fileset dir="${build.ldap}"/>
                <fileset dir="${build.mail}"/>
                <fileset dir="${build.mongodb}"/>
                <fileset dir="${build.native}"/>
                <fileset dir="${build.tcp}"/>
                <fileset dir="${build.test}"/>
            </classfiles>
            <sourcefiles encoding="${encoding}">
                <fileset dir="${src.components}"/>
                <fileset dir="${src.core}"/>
                <fileset dir="${src.functions}"/>
                <fileset dir="${src.jorphan}"/>
                <fileset dir="${src.junit}"/>
                <fileset dir="${src.ftp}"/>
                <fileset dir="${src.http}"/>
                <fileset dir="${src.java}"/>
                <fileset dir="${src.jdbc}"/>
                <fileset dir="${src.jms}"/>
                <fileset dir="${src.ldap}"/>
                <fileset dir="${src.mail}"/>
                <fileset dir="${src.mongodb}"/>
                <fileset dir="${src.native}"/>
                <fileset dir="${src.tcp}"/>
                <fileset dir="${src.test}"/>
            </sourcefiles>
        </structure>
        <html destdir="reports/coverage"/>
        <xml destfile="reports/coverage/jmeter-coverage.xml"/>
        <csv destfile="reports/coverage/jmeter-coverage.csv"/>
    </jacoco:report>
  </target>

  <target name="coverage-travis"  depends="ant-version,_coverage.prepare, test, _coverage.report"/>

  <target name="coverage"  depends="ant-version,_coverage.prepare, test-both, _allbatchtests, init-svnVersion, _coverage.report"/>

  <target name="_check_exists" if="_check_exists">
    <fail message="Invalid call sequence - file.exists should not be defined" if="file.exists"/>
    <available file="${file}" property="file.exists"/>
    <fail message="Could not find file ${file}" unless="file.exists"/>
    <antcall target="_checkSHA512">
      <param name="file" value="${jar}"/>
      <param name="path" value="${path}"/>
      <param name="sha512"  value="${sha512}"/>
    </antcall>
    <!--echo level="info" message="Found ${file}"/-->
  </target>

  <target name="check_jars" description="Check that all required jar files are present" unless="no_check_jars">
    <antcall target="_process_all_jars">
      <param name="_check_exists" value="true"/>
    </antcall>
  </target>

  <!-- Need to define config_loc for use by Eclipse -->
  <property name="config_loc" value="."/>
  <target name="checkstyle">
    <available property="checkstyle.jar.available" file="${lib.opt}/${checkstyle-all.jar}"/>
    <fail message="This task requires checkstyle, please run download_checkstyle target to download checkstyle"
          unless="checkstyle.jar.available"/>

    <antcall target="_process_checkstyle_jars"/>
    <taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
             classpath="${lib.opt}/${checkstyle-all.jar}"/>
    <checkstyle config="checkstyle.xml">
      <fileset dir="." includes="test/**/*,src/**/*"/>
      <formatter type="plain"/>
      <formatter type="xml" toFile="build/checkstyle_errors.xml"/>
    </checkstyle>

  </target>

  <target name="rat">
    <available property="rat.jar.available" file="${lib.opt}/${rat.jar}"/>
    <fail message="This task requires Apache Creadur RAT, please run download_rat target to download it"
          unless="rat.jar.available"/>
    <taskdef
      uri="antlib:org.apache.rat.anttasks"
      resource="org/apache/rat/anttasks/antlib.xml">
      <classpath>
        <pathelement location="${lib.opt}/${rat.jar}"/>
        <pathelement location="${lib.opt}/${rat-tasks.jar}"/>
      </classpath>
    </taskdef>
    <mkdir dir="${basedir}/reports/" />
    <rat:report reportfile="reports/rat-report.txt">
        <fileset dir="." excludesfile="rat-excludes.txt"/>
    </rat:report>
    <loadfile property="rat-errors" srcFile="reports/rat-report.txt">
      <filterchain>
        <linecontains>
          <contains value="Unknown"/>
        </linecontains>
      </filterchain>
    </loadfile>
    <echo message="reports/rat-report.txt:"/>
    <echo message="${rat-errors}"/>
  </target>

  <target name="sign_dist"
    description="Sign release artifacts in dist and dist/maven.  Usage: ant sign_dist -Dgpg.keyname=key-id [-Dgpg.secretKeyring=path-to-keyring]      ">
    <scriptdef name="gpg" language="beanshell">
      <classpath>
        <pathelement location="${lib.dir}/${beanshell.jar}"/>
      </classpath>
      <element name="fileset" type="fileset"/>
      <![CDATA[
      int execcode( String command ) // helper
      {
          StringTokenizer st = new StringTokenizer(command);
          String[] cmdarray = new String[st.countTokens()];
          for (int i = 0; st.hasMoreTokens(); i++) {
              cmdarray[i] = st.nextToken();
          }
          // Merge stderr with stdout so only have to fetch one stream
          proc = new ProcessBuilder(cmdarray).redirectErrorStream(true).start();
          din = new DataInputStream( proc.getInputStream() );
          while( (line=din.readLine()) != null ) {
              print(line);
          }
          return this.proc.waitFor();
      }
        keyname = project.getProperty("gpg.keyname");
        // Java 1.6 returns void, Java 1.5 returns null
        if (keyname == void || keyname == null) {
          self.fail("Please provide the gpg.keyname property");
        }
        keyring = project.getProperty("gpg.secretKeyring");
        if (keyring == void || keyring == null) {
          keyring = "secring.gpg"; // the default
        }
        sep=java.io.File.separator;
        cmd="gpg2 --batch --yes -ba -u " + keyname + " --secret-keyring " + keyring;
        self.log("Command: "+cmd);
        filesets = elements.get("fileset");
        for (i = 0; i < filesets.size(); ++i) {
          fileset = filesets.get(i);
          basedir = fileset.getDir();
          self.log("Processing "+basedir);
          ds = fileset.getDirectoryScanner();
          srcFiles = ds.getIncludedFiles();
          for (j=0; j < srcFiles.length; j++) {
            srcFile=srcFiles[j];
            file=basedir + sep + srcFile;
            self.log("Signing "+srcFile);
            ret=execcode(cmd+ " " + file);
            if (ret != 0) {
               self.fail("Command failed: "+ret);
            }
          }
        }
      ]]>
    </scriptdef>
    <gpg>
      <fileset dir="${dist.dir}"  includes="*.*" excludes="*.asc *.sha512"/>
      <fileset dir="${maven.dir}" includes="*.*" excludes="*.asc *.sha512"/>
    </gpg>
  </target>

  <path id="sonar.classpath">
    <fileset dir="./lib/opt" includes="**/*.jar" />
  </path>


  <target name="_sonar">
    <property environment="env" />
    <property name="sonar.organizationName" value="Apache" />
    <property name="sonar.projectName" value="JMeter" />

    <property name="sonar.projectKey" value="org.apache.jmeter:${sonar.projectName}" />
    <property name="sonar.projectVersion" value="${jmeter.version}" />
    <property name="sonar.language" value="java" />
    <property name="sonar.links.homepage" value="http://jmeter.apache.org" />
    <property name="sonar.links.ci" value="https://builds.apache.org/job/JMeter-trunk/" />
    <property name="sonar.links.scm" value="http://jmeter.apache.org/svnindex.html" />
    <property name="sonar.links.issue" value="http://jmeter.apache.org/issues.html" />
    <property name="sonar.modules" value="core,http,ftp,java,jdbc,ldap,mail,components,functions,jorphan,tcp,jms,native" />
    <property name="sonar.java.binaries" value="${build.core},${build.http},${build.core},${build.http},${build.ftp},${build.java},${build.jdbc},${build.ldap},${build.mail},${build.components},${build.functions},${build.jorphan},${build.tcp},${build.jms},${build.native}" />
    <property name="sonar.java.libraries" value="lib,lib/opt" />

    <property name="sonar.junit.reportsPath" value="reports" />
    <property name="sonar.jacoco.reportPath" value="reports/jacoco.exec" />

    <property name="sonar.issue.ignore.multicriteria" value="c1,c2,c3,c4,c5" />
    <property name="sonar.issue.ignore.multicriteria.c1.ruleKey"
           value="squid:S1948" />
    <property name="sonar.issue.ignore.multicriteria.c1.resourceKey"
           value="**/*.java" />
    <property name="sonar.issue.ignore.multicriteria.c2.ruleKey"
           value="squid:S00112" />
    <property name="sonar.issue.ignore.multicriteria.c2.resourceKey"
           value="**/*.java" />
    <property name="sonar.issue.ignore.multicriteria.c3.ruleKey"
           value="squid:MaximumInheritanceDepth" />
    <property name="sonar.issue.ignore.multicriteria.c3.resourceKey"
           value="**/*.java" />
    <property name="sonar.issue.ignore.multicriteria.c4.ruleKey"
           value="squid:S134" />
    <property name="sonar.issue.ignore.multicriteria.c4.resourceKey"
           value="**/*.java" />
    <property name="sonar.issue.ignore.multicriteria.c5.ruleKey"
           value="squid:S1192" />
    <property name="sonar.issue.ignore.multicriteria.c5.resourceKey"
           value="**/*.java" />
    <property name="sonar.coverage.exclusions"
           value="**/BSF*.java,**/org/apache/log/**.java,**/org/apache/jmeter/examples/**.java,**/org/apache/jorphan/logging/**.java" />
    <property name="core.sonar.projectName" value="core" />
    <property name="core.sonar.sources" value="${src.core}" />
    <property name="core.sonar.projectBaseDir" value="./" />
    <property name="http.sonar.projectName" value="http" />
    <property name="http.sonar.sources" value="${src.http}" />
    <property name="http.sonar.projectBaseDir" value="./" />
    <property name="ftp.sonar.projectName" value="ftp" />
    <property name="ftp.sonar.sources" value="${src.ftp}" />
    <property name="ftp.sonar.projectBaseDir" value="./" />
    <property name="java.sonar.projectName" value="java" />
    <property name="java.sonar.sources" value="${src.java}" />
    <property name="java.sonar.projectBaseDir" value="./" />
    <property name="jdbc.sonar.projectName" value="jdbc" />
    <property name="jdbc.sonar.sources" value="${src.jdbc}" />
    <property name="jdbc.sonar.projectBaseDir" value="./" />
    <property name="ldap.sonar.projectName" value="ldap" />
    <property name="ldap.sonar.sources" value="${src.ldap}" />
    <property name="ldap.sonar.projectBaseDir" value="./" />
    <property name="mail.sonar.projectName" value="mail" />
    <property name="mail.sonar.sources" value="${src.mail}" />
    <property name="mail.sonar.projectBaseDir" value="./" />
    <property name="components.sonar.projectName" value="components" />
    <property name="components.sonar.sources" value="${src.components}" />
    <property name="components.sonar.projectBaseDir" value="./" />
    <property name="functions.sonar.projectName" value="functions" />
    <property name="functions.sonar.sources" value="${src.functions}" />
    <property name="functions.sonar.projectBaseDir" value="./" />
    <property name="jorphan.sonar.projectName" value="jorphan" />
    <property name="jorphan.sonar.sources" value="${src.jorphan}" />
    <property name="jorphan.sonar.projectBaseDir" value="./" />
    <property name="tcp.sonar.projectName" value="tcp" />
    <property name="tcp.sonar.sources" value="${src.tcp}" />
    <property name="tcp.sonar.projectBaseDir" value="./" />
    <property name="jms.sonar.projectName" value="jms" />
    <property name="jms.sonar.sources" value="${src.jms}" />
    <property name="jms.sonar.projectBaseDir" value="./" />
    <property name="native.sonar.projectName" value="native" />
    <property name="native.sonar.sources" value="${src.native}" />
    <property name="native.sonar.projectBaseDir" value="./" />
    <condition property="sonar.host.url" value="${env.SONAR_HOST_URL}" else="http://localhost:9000">
      <isset property="env.SONAR_HOST_URL" />
    </condition>
    <condition property="sonar.login" value="${env.SONAR_LOGIN}">
      <isset property="env.SONAR_LOGIN" />
    </condition>
    <condition property="sonar.password" value="${env.SONAR_PASSWORD}">
      <isset property="env.SONAR_PASSWORD" />
    </condition>
    <condition property="sonar.jdbc.url" value="${env.SONAR_JDBC_URL}">
      <isset property="env.SONAR_JDBC_URL" />
    </condition>
    <condition property="sonar.jdbc.username" value="${env.SONAR_JDBC_USERNAME}">
      <isset property="env.SONAR_JDBC_USERNAME" />
    </condition>
    <condition property="sonar.jdbc.password" value="${env.SONAR_JDBC_PASSWORD}">
      <isset property="env.SONAR_JDBC_PASSWORD" />
    </condition>
    <property name="sonar.java.test.libraries" value="lib/**/*.jar" />

    <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
      <classpath refid="sonar.classpath" />
    </taskdef>

    <sonar:sonar xmlns:sonar="antlib:org.sonar.ant">
    </sonar:sonar>
  </target>

  <target name="sonar" depends="compile, install, coverage, _sonar" />

  <target name="nightlysonar" depends="_coverage.prepare, nightly, init-svnVersion, _coverage.report, _sonar, complete-junit" />

  <target name="setproxy" if="${proxy.use}">
    <setproxy proxyhost="${proxy.host}" proxyport="${proxy.port}"
              proxyuser="${proxy.user}" proxypassword="${proxy.password}" />
    <echo message="Using ${proxy.host}:${proxy.port} to download file"/>
  </target>

</project>
