Ant Utility Project Home Page

Overview

Wondering why your Ant build is slow? Is your continuous integration server taking too long to produce your project builds? This project may help.

This project includes a small number of classes for use with Ant that can help you to analyze your build in a non-intrusive manner.

How It Works

Ant provides some great facilities for customization. One of them is the org.apache.tools.ant.BuildListener . By implementing a build listener, you can get detailed information about the build without changing your build scripts. This utility contains a build listener that gathers and accumulates timing metrics for your build, and produces a report. The report can be visually inspected, or loaded into a spreadsheet since it's in CSV format.

Analyze Your Build

Run your build from the command-line using the following syntax:
ant -listener net.java.antutility.BuildMetricsListener [target]

Running it on our build produces results like this:

BUILD METRICS:
Local Time, Child Time, Invocation Count, Type, Name, Location
76515, 0, 111, TASK, eclipse-plugin-dependency-classpath, /Users/dgreen/Documents/mdd-tools/build/ant/eclipse-plugin-build.xml:51: 
47919, 0, 102, TASK, javac, /Users/dgreen/Documents/mdd-tools/build/ant/eclipse-plugin-build.xml:105: 
37024, 0, 6, TASK, java, /Users/dgreen/Documents/mdd-tools/build/ant/eclipse-plugin-build.xml:234: 
34707, 0, 1, TASK, untar, /Users/dgreen/Documents/mdd-tools/com.maketechnologies.tlm.test.common/test.xml:50: 
32094, 0, 1, TASK, gunzip, /Users/dgreen/Documents/mdd-tools/com.maketechnologies.tlm.test.common/test.xml:49: 
16656, 0, 7, TASK, junit, /Users/dgreen/Documents/mdd-tools/build/ant/eclipse-plugin-build.xml:290: 
13383, 0, 1, TASK, copy, /Users/dgreen/Documents/mdd-tools/build/ant/eclipse-site-build.xml:45: 
9335, 0, 1, TASK, java, /Users/dgreen/Documents/mdd-tools/com.maketechnologies.tlm.test.common/test.xml:113: 
5151, 0, 1, TASK, copy, /Users/dgreen/Documents/mdd-tools/build/build.xml:445: 
5114, 0, 34, TASK, jar, /Users/dgreen/Documents/mdd-tools/build/ant/eclipse-plugin-build.xml:156: 
4927, 0, 7, TASK, javac, /Users/dgreen/Documents/mdd-tools/build/ant/eclipse-plugin-build.xml:196: 
4320, 0, 1, TASK, copy, /Users/dgreen/Documents/mdd-tools/build/build.xml:454: 
3748, 0, 1, TASK, exec, /Users/dgreen/Documents/mdd-tools/com.maketechnologies.tlm.web.framework.gen/build2.xml:49: 
3566, 0, 1, TASK, style, /Users/dgreen/Documents/mdd-tools/build/ant/docbook/docbook/build-internal.xml:189: 
3408, 0, 1, TASK, copy, /Users/dgreen/Documents/mdd-tools/build/build.xml:471: 
2977, 0, 1, TASK, java, /Users/dgreen/Documents/mdd-tools/build/swizzle/build.xml:36: 
2287, 0, 1, TASK, java, /Users/dgreen/Documents/mdd-tools/build/swizzle/build.xml:21: 
2213, 0, 1, TASK, copy, /Users/dgreen/Documents/mdd-tools/com.maketechnologies.tlm.test.common/test.xml:25: 
2205, 0, 117, TASK, taskdef, /Users/dgreen/Documents/mdd-tools/build/build.xml:40: 
2182, 0, 1, TASK, unzip, /Users/dgreen/Documents/mdd-tools/com.maketechnologies.tlm.test.common/test.xml:19: 
2106, 0, 7, TASK, junitreport, /Users/dgreen/Documents/mdd-tools/build/ant/eclipse-plugin-build.xml:314: 
1347, 0, 7, TASK, copy, /Users/dgreen/Documents/mdd-tools/build/ant/eclipse-plugin-build.xml:199: 
1259, 0, 1, TASK, zip, /Users/dgreen/Documents/mdd-tools/build/ant/eclipse-site-build.xml:54: 
1091, 0, 102, TASK, copy, /Users/dgreen/Documents/mdd-tools/build/ant/eclipse-plugin-build.xml:108: 
... snip ...
		

What it means

The build metrics are reported with the left-most column being the time spent performing a specific task (in milliseconds). Also listed is the time spent performing "child" tasks, the invocation count, the type of event (BUILD, TARGET or TASK), the name of the task or target, and the location (the build script file name and line number). The metrics are sorted by "Local Time" (descending)

The report makes it easy to determine the bottlenecks in the Ant build process much the same way as a Java profiler does, but without the headaches and overhead of running the build in a profiler. Since the Ant build script file name and line number are listed, it is really clear as to where the problems lie.

How To Run antutility

There are a few ways to run antutility, most of which have to do with classpath setup.

  1. Run your build with antutility on the classpath:
    Put the absolute path to antutility.jar on your classpath. On my mac, this means I do the following:
    $ export CLASSPATH=/Users/dgreen/Documents/antutility/trunk/java/dist/antutility.jar
    $ ant -listener	net.java.antutility.BuildMetricsListener [target]
    				
    where [target] is an optional ant target name
  2. Run your build with antutility in the Ant lib folder:
    Copy the antutility.jar into your Ant installation lib folder, then run your build as follows:
    $ ant -listener	net.java.antutility.BuildMetricsListener [target]
    				
    where [target] is an optional ant target name

After launching your ant build, the build should proceed normally. After the build has completed, antutility should create a report and print it to the console.

Where To Get It (Downloads)

Check the Documents and Files section for the latest version.