## Comparison Ant Task |

| The comparison ant task can be used to generate comparisons from a number of saved snapshots. For more information please consult the overview.

| You can integrate the command line comparison with your ant script (read about ant at ant.apache.org) by using the `compare` task that is provided in `{JProfiler installation directory}/bin/ant.jar`. To make the `compare` task available to ant, you must first insert a `taskdef` element that tells ant where to find the task definition. Here is an example of using the task in an ant build file:
          <taskdef name="compare"
                   classname="com.jprofiler.ant.CompareTask"
                   classpath="C:\Program Files\jprofiler4\bin\ant.jar"/>

          <target name="compare">
            <compare sortbytime="true">
              <fileset dir=".">
                <include name="*.jps" />
              </fileset>
              <comparison name="TelemetryHeap" file="heap.html"/>
              <comparison name="TelemetryThreads" file="threads.html">
                <option name="measurements" value="inactive,active"/>
                <option name="valuetype" value="bookmark"/>
                <option name="bookmarkname" value="test"/>
              </comparison>
            </compare>
          </target>
The `taskdef` definition must occur only once per ant-build file and can appear anywhere on the top level below the `project` element. Note: it is not possible to copy the `ant.jar` archive to the `lib` folder of your ant distribution. You have to reference a full installation of JProfiler in the task definition.

| The `compare` task supports the following attributes:
Attribute | Description | Required
--- | --- | ---
listfile | An file that contains a list of snapshot files that should be compared, one snapshot per line. The snapshot from a nested fileset will be prepended. | Only if no nested fileset is specified
sortbytime | Sort all supplied snapshot files by their file modification time. | No
ignoreerrors | Ignore errors that occur when options for a comparison cannot be set and continue with the next comparison. The default value is "false", i.e. the export is terminated, when the first error occurs. | No
The compare task can contain nested fileset elements to specify the snapshots that should be compared. If no fileset is specified, the listfile attribute of the compare task must be set. The compare task contains a list of comparison elements with the following attributes:
Attribute | Description | Required
--- | --- | ---
name | The comparison name. For a list of available comparison names, please see the help page on the command line executable. extension. | Yes
file | The output file name. The process for the output format selection is described in the overview. | Yes
The comparison element can optionally contain a list of option elements with the following attributes:
Attribute | Description | Required
--- | --- | ---
name | The option name. Each comparison has its own set of options. For a list of available comparison names and the corresponding options, please see the help page on the command line executable. | Yes
value | The value of the option. | Yes