Wednesday, December 9, 2009

Ant Build Analysis Gets A Facelift

Wondering why your Ant build is slow? Are your continuous integration builds taking too long? Analysis of Ant builds has had a major facelift, with a new version of Ant Utility now fully integrated into the Eclipse UI. With Ant Utility, you can run your build and get immediate feedback:

As your build runs, Ant Utility measures how much time is spent in Ant tasks and targets. When the build is complete, build metrics are presented in an Eclipse editor, showing exactly which parts of your build file are taking the most time. Double-click on an entry to open the build file in the Ant editor, with problematic lines presented in varying degrees of red depending on the level to which the task or target contributes to the overall build time.

Ant Utility is not designed to replace a full-fledged profiler, however it can give you fast insight into build file problems in the language of your build script. Ant Utility has almost no overhead and is simple to configure.

Ant Utility can be installed into Eclipse via the following update site:
https://antutility.dev.java.net/site/

To enable Ant Utility on your build, add
-listener net.java.dev.antutility.core.MetricsBuildListener to the Arguments section of your Ant launch configuration:

The Ant build must also be configured to run in the same VM as the Eclipse IDE:

At this point you can run your build. When your build completes successfully, build metrics will appear in Eclipse. Hopefully you're off to the races, returning to snappy, healthy builds in no time flat!

14 comments:

Mark Melvin said...

What are the requirements for this? Does it require the Ant UI plugin (and hence the JDT)? I was able to install it into a platform runtime, but I can't seem to access any part of it.

I have a product based on the platform runtime that uses the Ant core plugin to provide an Ant-based builder so I thought this would be an interesting experiment.

David Green said...

@Mark Ant Utility has dependencies on org.eclipse.ant.core and org.eclipse.ui.ide. The IDE dependency is just for the UI bundle; If the IDE dependency is a problem for you, you can get the Ant Utility core plug-in and provide your own UI integration.

Mark Melvin said...

@David
Those dependencies are fine as both are included in the platform runtime. I wonder what I am doing wrong? From the screenshot it looks like there should be a metrics view of some sort? I don't see any UI integration.
I'll dig deeper...

Mark Melvin said...

I see now - the UI is implemented as an editor not a view. I'll see if I can get the listener wired up to my builder and play with it.

Thanks!

David Green said...

@Mark I'm glad that you got it sorted out! One thing that may not be intuitive is that the results are only presented when the build finishes. Have fun!

Scott Castle said...

This is cool, David. I especially like how you've made the tasks clickable and how you hilight the trouble spots in the build.xml.

I work on a project that does something very similar with gnu make-based builds: http://www.sparkbuild.com/profiles/blogs/build-profiling-with

Alex said...

I installed Ant Build Analysis in Eclipse (3.3.2) as given in your article. Running an ant build results to the following ClassNotFoundException: net.java.dev.antutility.core.MetricsBuildListener.

To the adress of Mark you said there were dependencies to org.eclipse.ant.core and org.eclipse.ui.ide. Where do I get them from?

David Green said...

@Alex Ant Utility requires Eclipse 3.5 or greater to run. You can get a newer version of Eclipse from http://www.eclipse.org/downloads

As far as dependencies, if you're running the Eclipse IDE you'll have everything you need.

Alex said...

@David I see. Thanks for the fast reply.

josephhowell said...

Does your Ant Utility work for C, C++, and Fortran builds too? Thanks Joe

David Green said...

@josephhowell it really doesn't matter what you're building. If you use Ant for your build system, it'll just work.

Anonymous said...

The update site is down. Is this plugin still available?

David Green said...

@Anonymous this project was a victim of the great java.net migration.

The project has now moved to http://java.net/projects/antutility/

The update site works, but unfortunately you'll need java.net credentials: https://svn.java.net/svn/antutility~svn/trunk/www/site/

David Green said...

I've now pushed this project up to GitHub. See the antutility project page.