how to pass argument values to ant

H

harryos

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
can someone tell me how i can do this?
thanks
harry
 
A

Andreas Leitgeb

harryos said:
in short i need something like

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top