You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Scott Ellsworth <sc...@alodar.com> on 2001/10/30 01:05:19 UTC

Iterating a list?

I have a list of build files I need executed in a certain order, and in 
certain directories.  I would like to get this down to just a couple of 
separated lists of project names.  I can do this if I can iterate through a 
list in order, but I do not know how to do that.

Assume I have a list of ant build files I want run:

/org/mine/build/foo
/org/mine/build/bar

and

com/employers/stuff/build/hi
com/employers/stuff/build/mom

I can set up:

   <property name="orgtargets" value="foo,bar"/>
   <property name="orgbuilddir" value="org/mine/build"/>
   <property name="comtargets" value="hi,mom"/>
   <property name="combuilddir" value="com/employers/stuff/build"/>

My build targets could be:

   <target name="build-debug">
     <property name="builddirectory" value="${orgbuilddir}"/>
     <for each org target>
       <property name="buildproject" value="orgtarget[i]" >
       <ant dir="${builddirectory}/{buildproject}" target="${buildcommand}"/>
     <end for>
     <property name="builddirectory" value="${combuilddir}"/>
     <for each com target>
       <property name="buildproject" value="comtarget[i]" >
       <ant dir="${builddirectory}/{buildproject}" target="${buildcommand}"/>
     <end for>
   <target>

This then would do

<ant dir="/org/mine/build/foo"/>
<ant dir="/org/mine/build/bar"/>
<ant dir="com/employers/stuff/build/hi"/>
<ant dir="com/employers/stuff/build/mom"/>

Is there any way to do this?

Scott
Scott Ellsworth
scott@alodar.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Iterating a list?

Posted by Matthew Inger <ma...@sedonacorp.com>.
let the flames fly.... that's a touchy subject around here.......
very scripty.....  If you really want a foreach task, i'll
send you one.  There is the "apply" task, but it assumes you
want to execute an OS command on it.

the one i have would look like:

<target name="doStuff">
  <echo message="param="${org}" />
</target>

<target name="doTheLoop">
  <foreach list="org1,org2"
           delimiter=","
           param="org"
           target="doStuff" />
</target>

On Mon, 2001-10-29 at 19:05, Scott Ellsworth wrote:
> I have a list of build files I need executed in a certain order, and in 
> certain directories.  I would like to get this down to just a couple of 
> separated lists of project names.  I can do this if I can iterate through a 
> list in order, but I do not know how to do that.
> 
> Assume I have a list of ant build files I want run:
> 
> /org/mine/build/foo
> /org/mine/build/bar
> 
> and
> 
> com/employers/stuff/build/hi
> com/employers/stuff/build/mom
> 
> I can set up:
> 
>    <property name="orgtargets" value="foo,bar"/>
>    <property name="orgbuilddir" value="org/mine/build"/>
>    <property name="comtargets" value="hi,mom"/>
>    <property name="combuilddir" value="com/employers/stuff/build"/>
> 
> My build targets could be:
> 
>    <target name="build-debug">
>      <property name="builddirectory" value="${orgbuilddir}"/>
>      <for each org target>
>        <property name="buildproject" value="orgtarget[i]" >
>        <ant dir="${builddirectory}/{buildproject}" target="${buildcommand}"/>
>      <end for>
>      <property name="builddirectory" value="${combuilddir}"/>
>      <for each com target>
>        <property name="buildproject" value="comtarget[i]" >
>        <ant dir="${builddirectory}/{buildproject}" target="${buildcommand}"/>
>      <end for>
>    <target>
> 
> This then would do
> 
> <ant dir="/org/mine/build/foo"/>
> <ant dir="/org/mine/build/bar"/>
> <ant dir="com/employers/stuff/build/hi"/>
> <ant dir="com/employers/stuff/build/mom"/>
> 
> Is there any way to do this?
> 
> Scott
> Scott Ellsworth
> scott@alodar.com
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
-- 
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 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>