Friday, January 14, 2011

Debugging Ant Tasks with Self Hosting

Do you know that Eclipse Ant support has debugging capabilities?

If not, check out this tutorial to get started.

Do you know how to self-host with Eclipse to test plug-ins?

If not here is a quick overview.

To debug ant tasks in a self hosted environment, the tasks must be included in a plug-in project.  If you are working with tasks outside of a plug-in development scenario, you can use remote debugging instead.  Here is a blog post to get you started.

Scenario:


You are developing an ant task to be included in an Eclipse plug-in.  You have the java code to execute the task in a plug-in that defines the task as an ant task extension in the plug-in xml.  The task runs, but the output is a bit off.  Time to start debugging.


1) Start a runtime workbench

Same as you would when debugging any other plug-in.

2) Create a new ant script

It doesn't matter what kind of project you put the script in.

Fill in the script with the proper targets and properties.  When calling your tasks, you will have to put in their full name as defined in the org.eclipse.ant.core.antTasks extension.  When running from a built jar, just the name of the class is satisfactory, but when self hosting we need the full name.

3) Create a new ant launch configuration

Right click on the script and hold down Ctrl while clicking "Debug > Ant Script".  You can also open the launch config dialog from the main menu, "Run > External Tools > External Tools Configurations".

4) Set up configuration options

Give the configuration a name.  On the JRE tab, select "Run in the same JRE as the workspace".  If you don't change this option, debugging won't work correctly.

5) Run the configuration

If there is a problem running the task, check that you have the full name of the task written in.  You can also check that Ant knows about your task by looking on the Ant > Runtime preference page (the Tasks tab will list all known tasks).

6) Start debugging

Set some breakpoints in the host workspace.  Make sure you debug your ant script (not just run it).

Note: Hot Code Replace does not work when debugging this way as the jar containing the tasks must be rebuilt.

5 comments:

elegir hipoteca said...

Your blog is very informative and provide lots of ideas and inspiration. Thanks for sharing your knowledge

Webhosting said...

very good articles and help us....

Cheap Logo Design said...

Thank you for posting the great content…I was looking for something like this…I found it quiet interesting, hopefully you will keep posting such blogs….Keep sharing
Cheap Logo Design

Asicstigershoesstore said...

The shoes will be a beneficial partner Hogan Onlinewhile you are on the basketball course and showing yourself. In that case every audience's thought will be
Belstaff Mens Jackets caught by you. Thanks to these attentions foused on you, you will filled with energy and be the most Tiger Shoes excellent one on the course and at last with no qualm win the match.

sport information said...

Please let me know if you’re looking for a author for your weblog. You have some really great articles and I feel I would be a good asset. If you ever want to take some of the load off, I’d love to write some content for your blog in exchange for a link back to mine. Please send me an email if interested.