ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Ellsworth <sc...@alodar.com>
Subject Re: looping in ant
Date Fri, 25 Jan 2002 02:16:51 GMT

On Thursday, January 24, 2002, at 05:46  PM, Frank E. Weiss wrote:

> I'm curious what you're trying to do. Three pattern that involve 
> looping are 1) doing something for each element of a set,
[...]
> Ant can do 1) for a set of files that match a pattern. You can also 
> chain a style task with an ant task to do 1) for a set that can be 
> expressed with
> XPath, but that involves using XSLT.

For my cruise control master build script, I want to build twenty 
projects.  Each needs to be checked out from cvs, compiled, and jarred.  
I have a target "build.one.target" that will happily do

I would love to be able to say:

   <property name="comtargets" value="framework,viewer,importer,printer"/>

I would love to write:

   <target name="build-all-projects" description="Build all defined 
projects">
   	<echo message="Building com projects"/>
     <foreach project in build.projects>
       <antcall target="build-one-project">
         <param name="build.project" value="${project}"/>
       </antcall>
     </foreach>
   </target>

rather than

   <target name="build-all-projects" description="Build all defined 
projects">
   	<echo message="Building com projects"/>
     <antcall target="build-one-project">
       <param name="build.project" value="framework"/>
     </antcall>
     <antcall target="build-one-project">
       <param name="build.project" value="viewer"/>
     </antcall>
     <antcall target="build-one-project">
       <param name="build.project" value="importer"/>
     </antcall>
     <antcall target="build-one-project">
       <param name="build.project" value="printer"/>
     </antcall>
   </target>

The syntax gets kind of ugly when there are twenty projects that need 
building in some reasonable order, and where adding a new project 
happens monthly or more often.  With appropriate looping, all we need to 
do is have the developer make the appropriate build scripts with the 
proper targets in it, and the add one item to a property.  Further, with 
appropriate local overrides, he can change what is build merely by 
changing a property in a local file, rather than modifying the master 
build file.

Scott


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


Mime
View raw message