JDeveloper Gem: Debug Ant Scripts

I’m not sure if this feature of JDeveloper is widely known, but JDev allows you to debug ANT scripts as if they where java classes of a project.

I guess you normally don’t need to debug an ANT script, but sometimes it comes handy. A use case which comes up quite often lately is the installation for the FOD sample application. A couple of users have run into trouble running the MasterBuildScript from the FOD sample application. You can download the FOD sample from here.Be sure to load the FOD version for the JDeveloper version you are using.

After unzipping the demo you open the ‘Infrastructre’ work space from within JDev, open the ‘MasterBuildScript’ project and open the ‘Resources’ node. Here you find the ‘build.properties’ file which you need to adapt with your environmental settings.
Here is my sample build.properties file:

# Master Ant properties file for Fusion Order Demo
# All build files refer to this master list of properties
# Continuous builds override these settings
# $Id: build.properties 812 2007-02-20 07:14:33Z lmunsing $

# Base Directory for library lookup

# JDBC info used to create Schema

# Information about the default setup for the demo user.

Now, to debug an ANT script, open the build.xml file in the MasterBuildScript project and search for the ‘init’ target. Here you set a break point as if this were a java source file.

'init' Taget

'init' Taget

Now right click the ‘build.xml’ file and select ‘Debug Ant Target…’ from the list. From the submenu you select the ‘buildAll’ traget.

Select Target to Debug

Select Target to Debug

You should quickly hit the break point set on the ‘init’ target. You can step over (F8) or step into (F7) like you can do with normal Java files. Best feature (which is the reason for the blog post) is that you can see and change the properties defined by the ANT script.

See and change ANT properties

See and change ANT properties

This should help you find bugs in ANT scripts and hopefully solve them too.

Chris Muir (in his comment) pointed to one more use case which should be mentioned. To get even more knowledge about the targets which are executed in an ANT script you can set more options. To get to the dialog you select ‘Advanced…’ from the list of targets

Select  'Advanced...' to get to more options

Select 'Advanced...' to get to more options

Then you select the target for which you want to set more options
Select target

Select target

and then go to the ‘Options’ step to set e.g. ‘Verbose’ output
Set 'Verbose' option

Set 'Verbose' option

When you finished the dialog the selected target starts running and produces this output
Verbose output

Verbose output

The interesting part is, that using the ‘Advances…’ target only sets the options for the one run or debug of the selected target. If you like to set one of the options permanently, you can do this in the ‘Manage Ant Settings…’ or the project settings
Permanent settings of options

Permanent settings of options

2 thoughts on “JDeveloper Gem: Debug Ant Scripts

  1. Ah, that would have been useful like 10,000 times in my past, thanks Timo!😉

    Something else worth pointing out is the “Advanced” option under the Ant targets list. This gives you the ability to run the Ant process in verbose and debug mode (equivalent to the command line “ant -versbose” and “ant -debug” options) giving more output to the console. This is often helpful when running some third party taskDef, as the log output is written to the console *hopefully* giving you an idea of why the process is not working correctly.


    • Chris,
      thanks for pointing this out. I missed this completely. I knew that that one can change the output level globally in the project settings (Ant->Options), but it never occurred to me that you can overwrite this setting for just one run of a target.
      I’ll add this to the blog post.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s