Debugging Eclipse’s PDE Build
22
Mar
2007
If you’re like me and have to deal with Eclipse’s PDE Build system on a regular basis, you’ll eventually find your build crashing without a lot of pertinent information. I’m writing this article to help those of you who are banging your heads against the wall trying to figure out why any of the tasks are failing. For the purposes of this article, I’m using Eclipse 3.2.2 SDK under Windows XP.
First of all, you’ll need to make sure you have the Eclipse SDK installed (with all the nice source plugins).. stepping through PDE code is gonna be hard without that. Next, you’ll need to make sure that your ant script is somewhere in the workspace under a Java project. I’ve created a simple java project called fetch-project with a simple ant script build.xml shown below:
<project default="main">
<property file="build.properties"/>
<target name="main">
<eclipse.fetch
elements="${type}@${id}"
buildDirectory="${buildDirectory}"
directory="${buildDirectory}/directory.txt"
fetchTag="${fetchTag}"
configInfo="${configs}"
baseLocation="${baseLocation}"
/>
</target>
</project>
and build.properties:
type=feature
id=org.jboss.ide.eclipse.feature
buildDirectory=C:/Build/rhds-build/eclipse
directory=${buildDirectory}/directory.txt
fetchTag=HEAD
configs=*,*,*
baseLocation=C:/Build/rhds-build/clean-eclipse
Now that we have a basic ant script that we can quickly edit and execute, let’s start setting up our project’s classpath so we can debug. First, you’ll need to add pdebuild.jar and pdebuild-ant.jar to your project’s build path. This can be done by following these steps:
- Right clicking on the project -> Build Path -> Configure Build Path
- Click on the “Libraries” tab
- Click “Add Variable”
- Click on the “ECLIPSE_HOME” variable, and then click the “Extend…” button
- Navigate down the tree, select plugins/org.eclipse.pde.build_x.x.x/pdebuild.jar (where x.x.x is your specific version), and press OK
- Repeat steps 3 and 4
- Navigate down the tree, select plugins/org.eclipse.pde.build_x.x.x/lib/pdebuild-ant.jar (where x.x.x is your specific version), and press OK
- Press OK to make the Properties window go away, and you should have a project structure that looks similar to this:

Next, we will need to point JDT to the source code for the two JARs we just added. This will allow us to set breakpoints, and step through the PDE Build internal code. Follow these steps:
- Right click on “pdebuild.jar” under your project, and click on “Properties”
- “Java Source Attachment” should already be selected. On the right side of the window we need to select the source attachment. Press the “Variable…” button.
- Choose “ECLIPSE_HOME” and press “OK”
- Now we need to extend the ECLIPSE_HOME variable and add the path to the source zip. Press the “Extension…” button.
- Navigate down the tree, select plugins/org.eclipse.pde.source_x.x.x/src/org.eclipse.pde.build_x.x.x/pdebuildsrc.zip (where x.x.x is your specific version), and press OK.
- Press OK to make the Properties window go away.
- Right click on “pdebuild-ant.jar” under your project, and click on “Properties”
- Repeat steps 2-4
- Navigate down the tree, select plugins/org.eclipse.pde.source_x.x.x/src/org.eclipse.pde.build_x.x.x/lib/pdebuild-antsrc.zip (where x.x.x is your specific version), and press OK.
- Press OK to make the Properties window go away.
- Expand pdebuild-ant.jar, and under it expand org.eclipse.pde.internal.build.tasks. You should see a class named “FetchTask” there. Double click it to open it in the classfile editor.
- If you see something like this, you are on your way

A note on debugging ant scripts in Eclipse. While Eclipse does have ant debugging support (right click on ant script > Debug As > Ant Build), it doesn’t support stepping through the actual implementation of the Java code of ant tasks. Luckily for us, there is a way around that using the antRunner Eclipse application.. so let’s set that up.
- Click on the “Run” top level menu in Eclipse, then click on “Debug…”
- Double-click on “Eclipse Application”.
- In the “Name:” textbox, enter a name that you can remember. I called it “fetch-debug”
- Looking a little further down you will see a “Program to Run” group, and under it two radio buttons. Choose the “Run an application” radio button.
- From the application dropdown, select org.eclipse.ant.core.antRunner.
- Click on the “Arguments” tab
- In the “Program Arguments” text box, type in the name of your build script. In my example this was simply “build.xml”.
- Further down in the “Working Directory” group, click the “Other” radio button, and press the “Workspace…” button to select a directory in the workspace.
- In the window that pops up, select the project that you’ve created, and press OK. In my case this was “fetch-project”. The text box should say something like “${workspace_loc:fetch-project}”.
- Press “Apply”, and then press “Close”.
At this point, the only thing left to do is to actually set a breakpoint, and debug our new Eclipse Application to inspect the code as it’s happening. I put a breakpoint on FetchTask.execute():

Next just “Debug” the new Eclipse Application you created by going back to the “Run” > “Debug” menu, and you should be hitting the breakpoint in no time! Note that if you are developing in an environment without plugin projects, when the breakpoint is reached, you may get a new editor that says “Source not found”. If you get this, click the “Edit Source Lookup Path…”, “Add…”, “Java Classpath Variable”,and repeat the steps above to point the configuration to the 2 source JARs under the ECLIPSE_HOME variable.
2 Responses to Debugging Eclipse’s PDE Build
Erik
September 25th, 2007 at 11:29 am
See http://eclipseassembly.sourceforge.net/
Adoams
October 30th, 2009 at 9:39 am
Is ti working? if i pass build.xml, it wrotes that there is no such target.
if i run without build.xml
Buildfile: E:\home\adomas\CI\tempProject1\build.xml
main:
BUILD FAILED
E:\home\adomas\CI\tempProject1\build.xml:4: Problem: failed to create task or type eclipse.fetch
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any / declarations have taken place.
Total time: 3 seconds