ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pugh, Eric" <EP...@MuseumCompany.com>
Subject RE: Passing in parameters (IF statement question)
Date Tue, 18 Sep 2001 15:26:11 GMT
I guess after reading and playing with some of the changes suggested, I am
getting closer to defining what i want!

I took Erik's suggestion, and created a batch file wrapper.  I have a task
called compare that invokes Beyond Compare to do a comparison of some file
directories.  My batch file takes in a "short name" for each enviroment.  In
other workds pl means production live.  ps means production stage.  I have
properties definied in my build.xml:
	${ps}  = \\production\stage
	${pl}  = \\production\live

These two parameters are passed into my ant compare task via the batch file.
Excellent so far, I can call bc.cmd ps pl and ant will get called with two
paramters set:  ant compare -Denviroment1=ps -Denviroment2=pl.  Then in my
ant task that exec's the BeyondCompare.exe I pass the two short names:
${enviroment1}.  However, what I am now discovering is that I am executing
this command:  
	c:\beyondcompare.exe pl ps.  
NOT
	c:\beyondcompare.exe \\production\live  \\production\stage

What I really want is to have some sort of IF statement that says
	IF ${enviroment1} = "ps" then
		${enviroment1} = ${ps}
	END if

This kind of scripting I know has been banned from ANT2, under the theory
that there are plenty of scripting tools.  So what have people done to make
this kind of functionality work?  Use the BSF stuff?

Eric

-----Original Message-----
From: Erik Hatcher [mailto:jakarta-ant@ehatchersolutions.com]
Sent: Tuesday, September 18, 2001 10:19 AM
To: ant-user@jakarta.apache.org
Subject: Re: Passing in parameters


If you truly mean "environment" variables in the operating system sense of
the term, you can set environment variables and access them via the Ant
property mechanism.   Check out the <property environment="...."/>
capability.

You have two options that I can suggest: 1) use the <property> task as
described above.  2) Write a custom wrapper script (this would be pretty
easy)

    Erik


----- Original Message -----
From: "Pugh, Eric" <EPugh@MuseumCompany.com>
To: <ant-user@jakarta.apache.org>
Sent: Tuesday, September 18, 2001 6:30 AM
Subject: RE: Passing in parameters


> In response to the two earlier replys....:
>
> 1) I am trying to pass an enviroment variable into ANT.  I want to copy a
> series of images and files to a webserver, and want to pass the name of
the
> webserver into ANT.  What I have done is just tack on a ton of methods, so
> instead of:
> ant deployAllImages webserver1
>
> I have multiple methods
> ant deployAlllImages-webserver1
> ant deployAlllImages-webserver2
> ant deployAlllImages-webserver3
>
> 2) The reasons I don't want to use the -D method is because I want to turn
> over the build/deploy scripts to a less technical, non java developer.
And
> requireing things like -D I think is going to be weird.  I guess I could
> have ant deployAllImages -Dserver=webserver1, but that is a long command
> line to remember.  And with multiple parameters, say deploy -Dtype=images
> -Dserver=webserver1 seems clumsier.  I don't want to create wrappers
because
> that is more to maintain, but maybe it is worth it.
>
> Eric
>
> -----Original Message-----
> From: Erik Hatcher [mailto:jakarta-ant@ehatchersolutions.com]
> Sent: Monday, September 17, 2001 8:16 PM
> To: ant-user@jakarta.apache.org
> Subject: Re: Passing in parameters
>
>
> What's wrong with -D?
>
> And how do you propose for Ant to support multiple targets on the
> command-line if targets and parameters are specified the same way?
>
> How about writing your own wrapper script that does the "-D" under the
hood
> and only allows a single target to be specified?
>
>     Erik
>
>
> ----- Original Message -----
> From: "Pugh, Eric" <EPugh@MuseumCompany.com>
> To: <ant-user@jakarta.apache.org>
> Sent: Monday, September 17, 2001 3:17 PM
> Subject: Passing in parameters
>
>
> > Is it possible to pass in parameters to ant?  Or is that completely
> against
> > the philosphy?
> >
> > I want to be able to pass in an enviroment parameter that does require
the
> > use of -Denviroment=stage.  Instead I want to be able to do:
> >
> > ant myproject stage
> > or
> > ant myproject live
> >
> > and so forth....
> >
> > I didn't seem to find anything directly related in the mail archives....
> >
> > ERic Pguh
> >
>

Mime
View raw message