Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > how to pass argument values to ant

Reply
Thread Tools

how to pass argument values to ant

 
 
harryos
Guest
Posts: n/a
 
      11-03-2008
hi
i have an ant buildfile in which i need to run java with different
arguments

<target name="runwith4andImage2" depends="jar">
<java fork="true" classname="${main-class}">
<classpath>
...
</classpath>
<arg value="${folder1}" />
<arg value="${folder2}/image2.jpg" />
<arg value="4" />
</java>
</target>

<target name="runwith7andImage1" depends="jar">
<java fork="true" classname="${main-class}">
<classpath>
...
</classpath>
<arg value="${folder1}" />
<arg value="${folder2}/image1.jpg" />
<arg value="7" />
</java>
</target>

....
here i think it will be better to pass the arguments image1.jpg and 7
along with ant call and use those arguments to set arg values inside
the target.I went thru the docs but I couldn't figure out how to do
it.
in short i need something like
>>ant run image1.jpg 7 sothat i can use the arguments from inside a single target run


can someone tell me how i can do this?
thanks
harry
 
Reply With Quote
 
 
 
 
Andreas Leitgeb
Guest
Posts: n/a
 
      11-03-2008
harryos <(E-Mail Removed)> wrote:
> in short i need something like
>>>ant run image1.jpg 7 sothat i can use the arguments from inside a single target run


Just recently I had the same problem, and didn't find
a satisfactory solution, myself.

If in your case the number of arguments is constant,
(the image name and a number), then you can help yourself
with properties. Your ant-invocation then looks like
this:

ant -Dfile=image1.jpg -Dnum=7 run

(which you can wrap in a shell script)
and the build.xml would contain something like this:

<java ...>
<arg value="${file}">
<arg value="${num}">
</java>

PS: I haven't tested it.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
error runing ant in eclipse ant view yihucd@gmail.com Java 1 03-07-2006 08:39 PM
trouble with Hibernate and Ant (probably just Ant) john martin Java 2 04-07-2005 09:27 PM
wondering how i can launch tomcat from ant without ant hanging... Chris Bedford Java 6 12-23-2004 12:41 AM
How to pass variable argument list to another function w/ variable argument list? Ben Kial C Programming 1 11-15-2004 01:51 AM



Advertisments