ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anthony Rodriguez <>
Subject RE: using ant in the deploy process
Date Fri, 21 Sep 2001 17:45:33 GMT
sweet!  This is exactly what I wanted to do.  Any chances this will be
included in Ant2?


-----Original Message-----
From: Matthew Inger []
Sent: Friday, September 21, 2001 10:43 AM
To: Ant User
Subject: RE: using ant in the deploy process

On Fri, 2001-09-21 at 13:11, Anthony Rodriguez wrote:

> 3) That is how I plan to do it.  I have a file called
> is loaded up in a target called "init" in my deploy.xml file.  I would
> a variable in the properties file called "site".  I wanted this variable
> be able to take one or more servernames, kind of like a list.  After
> thought I realized I could simulate this by incrementing a number and
> appending it to a prefix.  So, I would use 2 variables in the properties
> file "site" and "sitenum". So site=server and sitenum=1.  Then I could
> increment sitenum every time I call the deploy target so that I can deploy
> to server1, server2, etc.  That would solve my need for a list or array
> structure.
>   However I'm still left with the problem of iterating.  I would need a
> target, possibly the using the script task, that could iteratively call
> deploy target many times.  Every time the deploy target is called it would
> be passed the ${site}${sitenum + 1}.  Any thoughts on this?

scripting is an option, or you could use a custom task to do the
iteration, take a peek at the following build.xml fragment:

  <property name="site.sitelist" value="a,b" />
  <property name="site.a.server" value="host_a" />
  <property name="site.b.server" value="host_b" />

<target name="deploySite">
  <propertycopy name="server" from="site.${}.server" />

<target name="deployAllSites">
  <foreach list="${site.sitelist}"
           delimiter="," />

you'll notice that the first target uses the "propertycopy"
task, which essentially gives you a double dereference
(ie.   ${site.${}.server} ) which ant doesn't
allow you to do without javascript or a custom task.

the "deployAllSites" target uses the "foreach" task, which iterates
through the given list, calls a target for earch item in the
list, and sets a parameter (indicated with the "param" attribute)
to the current value in the list.
So, if your list was "1,2", it would be equivalent to:

   <antcall target="deploySite">
     <param name="" value="1" />

   <antcall target="deploySite">
     <param name="" value="2" />

for your convenience, i have attached implementations of these
tasks to this mail (they come in quite handy on my project, and
vastly improve the readability of the xml, virtually elimiating
all the javascript that i previously used to do this type of

Hope this can help you.

Matt Inger (
Sedona Corporation
455 S. Gulph Road, Suite 300
King of Prussia, PA 19406
(484) 679-2213
"Self-respect - the secure feeling that no one,
 as yet, is suspicious." -H.L. Mencken 

View raw message