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
jdeveloper.home=P:/jdeveloper
src.home=..//..
# JDBC info used to create Schema
jdbc.driver=oracle.jdbc.OracleDriver
jdbc.urlBase=jdbc:oracle:thin:@tdb02
jdbc.port=1521
jdbc.sid=ORCL
# Information about the default setup for the demo user.
db.adminUser=system
db.demoUser=FOD
db.demoUser.password=fusion
db.demoUser.tablespace=USERS
db.demoUser.tempTablespace=TEMP{code}
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.
Now right click the ‘build.xml’ file and select ‘Debug Ant Target…’ from the list. From the submenu you select the ‘buildAll’ traget.
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.
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
Then you select the target for which you want to set more options
and then go to the ‘Options’ step to set e.g. ‘Verbose’ output
When you finished the dialog the selected target starts running and produces this 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










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.
CM
Comment by Chris Muir — 8. February 2012 @ 04:04 |
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.
Timo
Comment by Timo Hahn — 8. February 2012 @ 08:08 |