A Few Ant Gotchas Using External Property Files (on Windows)

After watching John Paul Ashenfelter’s Pragmatic ColdFusion: Build, Test, Deploy preso I decided to try hacking up one of my Ant build scripts to use an external property file. It seemed like this would be a bit more flexible.

I initially just copied all my property statements from my build.xml’s “init” target to my external property file. And things ran up to a point and then I ran into

In my build.xml


In my common.properties file (note double slashes)

project.build.src = D:\\build\\${project.name}

Or you could do (note forward slashs)

project.build.src = D:/build/${project.name}

Also references to UNC paths changed:

In build.xml


In common.properties (note forward slashs)

project.build.dev = //myserver/${project.name}$

I’ve got a few properties still buried in my script that are dependent on certain targets but I think with a bit of tweaking I can reference those externally as well. Then ideally any developer on our team can simply tweak the external file without messing with the more complicated build.xml.

This article contains a few more good tips: Flexible User and Environment Ant Configuration which I’m going to implement as well.

Recent Related Posts

One thought on “A Few Ant Gotchas Using External Property Files (on Windows)

  1. MUCH more flexible, IMO. Having used properties files for a year or so, I’ve refined them to such a degree that I have “base” properties and build files which can be refined on a project-by-project basis. Once the project build file is complete, only the properties file needs to be modified in order to build/deploy that project to multiple servers (dev, staging, prod, etc.). Works beautifully.

    Properties files are easy to modify, script files…less so, I think. :-)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>