Arguments with ANT

E

Eric Farraro

I've been looking for a way to pass arguments to ANT, but have so far
been unsuccessful. I figured out how to pass them from the command
line:

ant -buildfile -Dmyarg=abc

.... but what I'd like to do, is have an ANT script call a different
ANT script, and pass the arguments along. So far, I have not figured
out how to pass arguments to an ANT script, from within another ANT
script. What I have is something like this:

(Inside build.xml):

<ant dir="${ant.exec.directory}" antfile="${ant.script.name}"
target="main" inheritAll="true"/>

I'd like to pass any arguments to 'ant.script.name' that 'build.xml'
receives. For instance, if there was a 'parameter' attribute, I could
use something like that.

Any suggestions?
 
R

Roedy Green

... but what I'd like to do, is have an ANT script call a different
ANT script, and pass the arguments along. So far, I have not figured
out how to pass arguments to an ANT script, from within another ANT
script. What I have is something like this:

You can put things in the set environment. I put the jar signing
password in there, for example.

I get at it like this:

<!-- get _your_ password from set jarsignerpassword=sesame -->
<!-- get _your_ code-signing certificate from set
cert=mindprodcert2008dsa -->
<property environment="env" />
<signjar jar="${jar.file}"
alias="${env.cert}" storepass="${env.jarsignerpassword}" />
 
A

Arne Vajhøj

Eric said:
I've been looking for a way to pass arguments to ANT, but have so far
been unsuccessful. I figured out how to pass them from the command
line:

ant -buildfile -Dmyarg=abc

... but what I'd like to do, is have an ANT script call a different
ANT script, and pass the arguments along. So far, I have not figured
out how to pass arguments to an ANT script, from within another ANT
script. What I have is something like this:

(Inside build.xml):

<ant dir="${ant.exec.directory}" antfile="${ant.script.name}"
target="main" inheritAll="true"/>

I'd like to pass any arguments to 'ant.script.name' that 'build.xml'
receives. For instance, if there was a 'parameter' attribute, I could
use something like that.

inheritAll="true" will pass all existing properties.

To pass new properties use:

<ant dir="${ant.exec.directory}" antfile="${ant.script.name}"
target="main" inheritAll="true">
<property name="myarg" value="abc"/>
</ant>

Arne
 

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

Forum statistics

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

Latest Threads

Top