ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Mehdi.Rakhsh...@gxs.com>
Subject RE: How to access command line arguments passed to Ant. How to search Ant manual
Date Wed, 08 Mar 2006 13:07:14 GMT
I have a .bat file that starts Ant with the parameters that the user
specifies. The reason I want to use the argument instead of using -D is
that different targets have different parameters passed to them. For
example, if I am building my test tool, the second parameter should be
the server name, if I am building a package, the second parameter should
be the package type. Unless I make the .bat file know about different
targets and set -Dserver in the first case and -DpackageType in the
second case, I have to use something generic like -Darg2=%2. It seems
more elegant if the .bat file did not have to know about different
arguments, it would just pass them to Ant(along with the target) and the
Ant file would use the arguments as needed. Since there does not seem to
be a way to do that, I have resorted to using the -Darg2 approach.

 

Thanks,

Mehdi Rakhshani

BES-IT Development, GXS

813-496-3624

-----Original Message-----
From: notify@yahoogroups.com [mailto:notify@yahoogroups.com] On Behalf
Of schmaxelander
Sent: Wednesday, March 08, 2006 7:51 AM
To: Rakhshani, Mehdi (GXS)
Subject: Re: How to access command line arguments passed to Ant. How to
search Ant manual

 

Hi Mehdi,

 

--- In apache-ant@yahoogroups.com, <Mehdi.Rakhshani@...> wrote:

> I went through as much of the Ant manual as I could and did not find
any

> information that tells me how to use a command line argument that was

> passed to Ant (I am sure it is there and I missed it).

> 

> [...]

> 

> 2-       If I call Ant with "target argument_needed_by_target" how do
I

> use the second argument in my target? (I know about using

> -Dmyproperty=%2 but am looking for a better option)

 

Well, you seem to know the standard way of doing so: "-Dmyproperty=...".

 

Counterquestion: why are you looking for a different way?

Even if there might be better ways (which I doubt), this is the

standard. 

 

Regarding your example "ant ... target argument_needed_by_target": 

ANT interprets these parameters as target names.

So if you don't add "-D" in front of your argument, ANT can't identify

it as such.

 

~Alex

 

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message