This was discussed on the mailing list a couple of times...here a link to the latest time is was discussed: http://marc.theaimsgroup.com/?l=ant-user&m=113040722211523&w=2 (And a reasonable solution is offered, yea !!)
----- Original Message ---- From: [EMAIL PROTECTED] To: user@ant.apache.org Sent: Wednesday, March 8, 2006 7:07:14 AM Subject: RE: How to access command line arguments passed to Ant. How to search Ant manual 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:[EMAIL PROTECTED] 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 [EMAIL PROTECTED], <[EMAIL PROTECTED]> 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