Nice solution :)

Anderson, Rob (Global Trade) wrote:
Often there are a set of properties you might use with a given
environment. I suggest creating a properties file for each environment
like so...

localhost.properties
=====================
ip.address=100.10.0.48
deploy.path=/usr/local/tomcat/webapps
remote.user=tomcat

Then in your build.xml you would load the properties file with...

<property file="${env}.properties"/>

And run ant by passing in the env property...

ant -Denv=localhost target

You can also include some error checking targets/tasks for sanity...

<fail unless="env">You must specify the env property when you run
ant.</fail>
<available property="env.prop.file.exists" file="${env}.properties"/>
<fail unless="env.prop.file.exists">Cannot find ${env}.properties
file.</fail>

...or...

<target name="get.env" unless="env">
  <input defaultvalue="localhost" message="What environment?"/>
  <available property="env.prop.file.exists" file="${env}.properties"/>
  <fail unless="env.prop.file.exists">Cannot find ${env}.properties
file.</fail>
</target>

-Rob Anderson

-----Original Message-----
From: wolverine my [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 21, 2006 3:48 AM
To: Ant Users List
Subject: 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to