yeomanly

Cool Ant file trick and concept

2008 June 25
tags: Ant
by Mike Henke

I watched Qasim Rasheed's CFUnited presentation on Continuous Integration with SVN, ANT, CFUnit & Selenium. I picked up a fundamental concept, Conditional Execution, and a cool trick.

The concept was the if and unless attribute of an ant target. I have read about them but it was great to see them in action. He covered it quick so I had to watch that section a couple times.

Basically:

<target name="if" if="propertyName" …>

I run if propertyName is define

</target>

<target name="unless" unless="propertyName" …>

I run if propertyName is NOT defined

</target>

so

<property name="propertyName" value="true" />

<target … depends="if,unless" >

hello

</target>

Both targets would be called but if would only actually run. If propertyName wasn't defined both targets would be called but only unless would actually run.

The trick was in an Ant File (using the Ant Editor – thanks Jim) pressing Ctrl and mouse over properties (example ${property}) , the ${property} will turn blue and underlined.

If you click the ${property}, the editor will jump to where the property is defined in the file. If the property was set in a property file, the editor will jump to where the property file is defined in the ant file.

If you hold Ctrl and click on the property file, the editor will open up the file. Pretty sweet.

I wonder how Ant files are doing this since it would be interesting to have this feature in CFEclipse for some variables. I guess this Ctrl-Click feature is – Go to declaration of object at cursor.

Cool Ant file trick and concept

4 Responses leave one →
  1. Jim Priest
    Jun 26, 2008 at 7:09 AM

    Say what? I have to have some caffeine and read this again :)

  1. Jim Priest
    Jun 26, 2008 at 7:15 AM

    Ah ha! I've never seen this before so I couldn't figure out what you were talking about.

    I was opening the .xml files with the Aptana editor. To see this behavior you need to do "Open with... Ant Editor".

    Though it won't open this: ${user.name}.properties

    Very cool! Will add to the wiki!

  1. Mike Henke
    Jun 26, 2008 at 7:29 AM

    Jim is right, I didn't mention I am using the Ant Editor. Thanks

  1. Qasim Rasheed
    Jun 29, 2008 at 8:34 PM

    Mike,

    Glad to hear that you were able to find something useful in my session. By the way, I have just release the code and presentation on my site at

    http://qasimrasheed.com/blog/index.cfm/2008/6/29/CFUnited--code-and-presentation

Leave a Reply

Leave this field empty: