ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Inger <ma...@sedonacorp.com>
Subject RE: using ant in the deploy process
Date Fri, 21 Sep 2001 17:43:29 GMT
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 deploy.properties.  It
> is loaded up in a target called "init" in my deploy.xml file.  I would have
> a variable in the properties file called "site".  I wanted this variable to
> be able to take one or more servernames, kind of like a list.  After further
> 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 the
> 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.${deploy.site}.server" />
</target>

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

you'll notice that the first target uses the "propertycopy"
task, which essentially gives you a double dereference
(ie.   ${site.${deploy.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="deploy.site" value="1" />
   </antcall>

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


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
stuff).

Hope this can help you.


-- 
Matt Inger (matt.inger@sedonacorp.com)
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 

Mime
View raw message