ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Donald <>
Subject Re: Question about properties and ant2
Date Fri, 14 Sep 2001 09:09:17 GMT
On Fri, 14 Sep 2001 01:26, Claudio Corsi wrote:
> > > The reason behind the implementation of these targets is that our xml
> > > file is starting to become large. I started to refractor the xml file
> > > to make it simpler to add new targets without adding too much to the
> > > xml file. This is where this idea came from and I really believe that
> > > this concept should be added if not already their.
> >
> > Support for these functions will be added in time (I have been calling
> > for it for about a year now) but it is unlikely to happen before Ant2.
> I guess I have become skeptical because of the fact that this feature can
> produce a single build.xml file that will include all the target. While
> being forced to use multiple xml files that are called by a top level
> build.xml file will enforce the concept of modularity. I must admit that I
> might not fully understand what you meant. If that is the case, I would
> like an
> example/clarification of what you propose.

Theres two forms of reuse we have talked about. Reuse of whole build files 
and reuse of build file parts (ie inter vs intra build file reuse). Basically 
for intra-file reuse you have to be able to make sure the dependencies in 
each build file are only executed once (ie a unified Directed Acyclic Graph 
rather than a separate DAG per project/invocation of ant/antcall).

The second form of reuse is reusing some parts of build file again. There has 
been a few proposals but they generally fall into one of two categories. 

One uses <target/> constructs like methods/functions where you "call" these 
passing parameters etc. To do this you need a few different things (mutable 
properties, lightweight antcalls, foreach tasks and extensive set of 
operations that manipulate properties scope).

The other way is to allow the level of "reuse" to be determined by build file 
writers. In this case you would have separate build file for "rules" and a 
separate file for "data" and the "rules" file would be reusable. XSLT seems a 
good standard to use for rules so you could do something like

<deploy name="blah" machine="blee" product="bloo" />

And this would be transformed by XSLT or whatever to actually be the 
following tasks

<mkdir dir="blah"/>
<unzip file="" todir="blah"/>
<scp address="" dir="blah" todir="/www/site/blah" />
<ssh address="" dir="/www/site/blah" 
command="" />
<delete dir="blah" />

or whatever. So in effect you can define your own task-like constructs ... 
alternatively you could redefine targets or whatever.

So it comes down to which form the ant committers think is simpler. Is

<deploy name="blah1" machine="blee" product="bloo" />
<deploy name="blah2" machine="blee2" product="bloo7" />
<deploy name="blah3" machine="blee1" product="bloo15" />
<deploy name="blah4" machine="blee" product="bloo43" />
<deploy name="blah5" machine="blee7" product="bloo2" />

<xsl:template match="deploy">
  <mkdir dir="{$name}"/>
  <unzip file="{$product}.zip" todir="{$name}"/>
  <scp address="{$machine}" dir="{$name}" 
       todir="/www/site/{$name}" />
  <ssh address="{$machine}" dir="/www/site/{$name}"
       command="" />
  <delete dir="{$name}" />


<property name="host1" value="blee"/>
<property name="host2" value="blee2"/>
<property name="host3" value="blee1"/>
<property name="host4" value="blee"/>
<property name="host5" value="blee7"/>
<property name="product1" value="bloo"/>
<property name="product2" value="bloo7"/>
<property name="product3" value="bloo15"/>
<property name="product4" value="bloo43"/>
<property name="product5" value="bloo2"/>

<foreach variable="x" in="1 2 3 4 5">
  <mkdir dir="blah${x}"/>
  <unzip file="${product${x}}.zip" todir="blah${x}"/>
  <scp address="${host${x}}" dir="blah${x}" 
       todir="/www/site/blah${x}" />
  <ssh address="${host${x}}" dir="/www/site/blah${x}"
       command="" />
  <delete dir="blah${x}" />

The second form is not directly reusable but could be made so by placing 
contents in another another build file and using ant task to call it up while 
the first can be moved from project to project with ease. I like the first 
form while others seem to prefer the second one with all it entails. (Namely 
recursive property evaluation, mutable property values, potentially scoping 
issue etc).



you've made a dangerous leap right over common 
sense, like some kind of metaphysical Evil Knievel

View raw message