You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by wolverine my <wo...@gmail.com> on 2006/06/21 12:48:05 UTC

Can we pass parameter to Ant target?

Hi!

Is it possible to pass parameters/arguments to a Ant target?
For an example,

> ant deploy localhost

where we specify the deployment server as a parameter when invoking
the "deploy" target. The "localhost" could be another property defined
in the build file,

  <property name="localhost" value="100.10.0.48"/>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Can we pass parameter to Ant target?

Posted by "Scot P. Floess" <fl...@mindspring.com>.
Ben:

Good point ;)  Was a wee bit early when I responded :)

Scot

Ben Stringer wrote:
> On Wed, 2006-06-21 at 06:57 -0400, Scot P. Floess wrote:
>   
>> You can sorta do that if you use -D's to define property values.
>>
>> For instance:
>>
>> ant -Dserver=localhost deploy
>>
>> Then you can use:
>>
>> ${server}
>>
>> in your ant script...
>>
>> Or you can use a property file as well...
>>     
>
> Or environment variables.
>
> EG.
>
>   <property environment="env"/>
>   <echo>${env.HOSTNAME}</echo>
>
> Cheers, Ben
>
>
>
>   

-- 
Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-754-4592 (Work)

Chief Architect JPlate  http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim


Re: Can we pass parameter to Ant target?

Posted by Ben Stringer <be...@burbong.com>.
On Wed, 2006-06-21 at 06:57 -0400, Scot P. Floess wrote:
> You can sorta do that if you use -D's to define property values.
> 
> For instance:
> 
> ant -Dserver=localhost deploy
> 
> Then you can use:
> 
> ${server}
> 
> in your ant script...
> 
> Or you can use a property file as well...

Or environment variables.

EG.

  <property environment="env"/>
  <echo>${env.HOSTNAME}</echo>

Cheers, Ben



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Can we pass parameter to Ant target?

Posted by "Scot P. Floess" <fl...@mindspring.com>.
You can sorta do that if you use -D's to define property values.

For instance:

ant -Dserver=localhost deploy

Then you can use:

${server}

in your ant script...

Or you can use a property file as well...



wolverine my wrote:
> Hi!
>
> Is it possible to pass parameters/arguments to a Ant target?
> For an example,
>
>> ant deploy localhost
>
> where we specify the deployment server as a parameter when invoking
> the "deploy" target. The "localhost" could be another property defined
> in the build file,
>
>  <property name="localhost" value="100.10.0.48"/>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

-- 
Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-754-4592 (Work)

Chief Architect JPlate  http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org