Debugging Easy/Ant Scripts

A few weeks back, I had been wondering on support for diagnostic functionality for EasyAnt. Trying to search for a starting point, I was drawn to Ant Diagnostics. Try this out:

ant -diagnostics

The output is interesting. Ant scans and lists quite a few helpful setup and environment bits, including the ant version, Ant libraries, a number of system properties etc. Such information is quite helpful when troubleshooting setup or environment issues. But – what if problems being faced are actually problems with the scripts themselves?

Would debugging be more useful in such cases? So there is an effort to build a debugger, that can be driven from the command line itself.

The debugger is built into a separate jar, that you can add to the Ant classpath (use the -lib argument). The debugger library essentially contains a simple build listener that pauses build execution at breakpoints, that you can specify through a debug prompt (that you get when you run the build with the debug listener). There are a list of debug commands that you can issue from this prompt and inspect the state of your build.

– break <target>: Adds a breakpoint at a target
– watch <property>: Adds a watchpoint at a property
– inspect property <property.name>: Shows the current value of a property
– inspect path <some.path>: Shows the current value of a path
– locate property <property.name>: Shows the exact location of the property declaration in build files
– return: Resumes the build execution

An initial POC is in place and can be found here: https://svn.apache.org/repos/asf/incubator/easyant/tasks/trunk/command-line-debugger. You should find a README file at this location with instructions on how to try it out. Currently, it does not have any step through functionality. The build may be paused – you may inspect as much as you wish, and you can then resume the build.

The following are planned:
– Break points at specified exceptions
– Way to get information on all set breakpoints and watchpoints
– Way to set / unset / create new properties

While there are Ant debuggers in IDEs (I dont have much personal experience using them), hopefully this one will help some command line users.

  1. No Comments