Debugging Ant tasks in Eclipse

Today I came  an issue that required me to debug a custom Ant task that we have. While the Eclipse integrated debugger allows you to step through the targets and tasks in the build.xml file using the action Debug As -> Ant Script, it doesn’t actually let you step into the java class that implements the task. This is a major drawback, as most of the complexity (and issues :-)) tend to be in the task implementation code.

After searching around for a bit, I came across the Eclipse Remote Debugger debug configuration. This configuration allows you to remotely debug applications, by establishing a JDWP (Java Debug Wire Protocol, part of JPDA – Java Platform Debug Architecture) connection between the running application and the debugger. After learning about this, setting up the environment to debugg Ant tasks from within Eclipse was pretty straightforward.

The first step is to setup the Ant script launcher to run in debug mode and attach to the debug server. The following should be used as JRE arguments for the Ant configuration:

-Xdebug -agentlib:jdwp=transport=dt_socket,server=y,address=8000

You can setup your Ant configuration by going to Run -> External Tools -> External Tools Configurations and creating a new Ant Build configuration. Inser the location of the build file in the main tab and setup the arguments in the JRE tab:

After the Ant configuration is setup, we need to take care of the remote debugger configuration. Go to Run -> Debug Configurations… and create a new configuration for Remote Java Application. Make sure you set the same port number that you used in the Ant configuration, and you are good to go.

Now, place the breakpoints in your build.xml and java classes. In order to debug, you need to first launch the Ant script and then attach the debugger to it. Do right click in the build.xml file and select Debug As -> Ant Script. Then go to Run -> Debug Configurations… select the Remote Ant Debugger and click Debug. The debugger will now attach to the running proccess and let you step through both the xml file and the java classes:

Have fun!


  1. Nicolas September 3, 2009

    Very usefull information. Thanks a lot.


  2. Nithya Srinivasan October 14, 2009


    Thanks for this.
    Overcame a big hurdle with this
    Ours was a little bit more complicated, since we also had testng sitting in the middle


  3. jg June 11, 2010

    Thank you for providing this information but I cannot get it to work at all (in eclipse) Without remote debugging args I can step through the ant script. With them the task simple terminates immediately.

    I will keep looking for a solution as it must be some small configuration issue. Perhaps the eclipse cabal will address this oversight in a new version


  4. Jason July 7, 2010

    Nice guide although I had a little trouble when I tried this in Helios. It turns out that the -Xdebug VM argument is not required and actually stops this from working as expected even though the remote debugger seems to attach properly.

    If you are having this issue where the ant thread and remote debugging thread are running but it doesn’t seem to be hitting your breakpoint and the debugging perspective does not show the current pointer then try use these VM arguments instead:

  5. Tanel January 21, 2011

    instead of Xdebug you can try using Xrunjdwp:

  6. dress January 30, 2011

    This dress is perfect Couture Wedding Dresses Plus size Wedding Dresses fantastic dress over all Maternity Wedding Dresses The dress is simple beautiful Destination Wedding Dresses Blue Wedding Dresses Vintage Wedding Dresses I fellcompletely in love with this dress when i saw it Unique Wedding Dresses Romantic Wedding Dresses Cocktail Dresses very hard for me to find something that fits good and it is perfect Evening Dresses Recieved this dress much sooner than expected and it is beautiful Celebrity Dresses Special Occasion Dresses Blue Wedding Gowns This dress is perfect Prom Dresses Sweet 16 Dresses Quinceanera Dresses.

  7. robinboy March 31, 2011

    Thanks,you help me resovled a big problem.
    Thank you very much again.

  8. Dinesh June 20, 2011

    I have followed all the above specified step above but debug point does not come on java. I have specified the JVM argument in workspace JRE.
    Please help me on this.

  9. Gustavo Sweatmon June 30, 2011

    Thank you very much for this professional and effective help.

  10. Coach calgary August 18, 2011

    Thanks a lot very much for the impressive and result oriented help.

  11. Kindi September 11, 2011

    Impressive! Thank you very much for sharing. It is really weird such information is hard to find. Someone has to “figure it out” then share it.

  12. myangel September 28, 2011
  13. Flassari October 27, 2011

    Fantastic, works like a charm.

Comments are Disabled