ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ivan Ivanov <>
Subject Re: idiom to pass ant command line args to java task?
Date Thu, 01 Dec 2005 22:58:07 GMT

you can have several options.
1) Provide the options as the value of one property
like this:
ant"-opt1 value1 -opt2 value2
-opt3 value3 ..."
Then in your build script grab them like this:
<java classname="...">
    <arg line="${}"/>

2) you can provide the value of each options as a
ant -Dopt1=value1 -Dopt2=value2 -Dopt3=value3 ...
<java classname="...">
    <arg value="-opt1"/>
    <arg value="${opt1}"/>
    <arg value="-opt2"/>
    <arg value="${opt1}"/>
    <arg value="-opt3"/>
    <arg value="${opt1}"/>

Note that in both cases you can provide in your build
script default values for those properties and specify
them on the command line only if you need them
different from the defaults.

1) is more flexible, since you can provide a random
number of agruments. But it is also inconvenient if
you want to change only one option to be different
from the default ones.


P.S. Also regardless of the way I pass options to my
Java programs I found that Jakarta CLI is a quite
usefull command line parser, that extracts easily the

--- Ray Tayek <> wrote:

> hi, i would like to say: ant run arg1 arg2 ... and
> have the run task 
> grab the args and pass them to  the <java> task as 
> <arg value="?"/>
> does anyone have an idiom for doing this? or must i
> use environment 
> variables or something else?
> thanks 
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message