ant-user mailing list archives

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

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

2) you can provide the value of each options as a
property:
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}"/>
...
</java>

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.

Regards
Ivan

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
options.

--- Ray Tayek <rtayek@comcast.net> 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:
> user-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> user-help@ant.apache.org
> 
> 



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


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message