Wednesday, August 26, 2009

Accessing system properties from Ant build file

I need to do some tasks via shell scripts. Among those tasks are also ant scripts. Sometimes I need to pass some arguments to ant script from shell scripts. I've found that this can be done through java system properties. Those properties are easily accessed from ant build file - just like properties declared in build file itself: ${}
Here is a brief example. The build file cool-build.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project name="FunProject" default="work" basedir=".">
<target name="work">
<echo message="${}">

We, run it with passed system property
ant -f cool-build.xml
And the result is:
Just as expected :)

No comments: