ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dominique Devienne" <DDevie...@lgc.com>
Subject RE: lists of lists
Date Tue, 28 Sep 2004 04:10:17 GMT
> From: Ray Madigan [mailto:ray@madigans.org]
> I have a complicated development environment and want to do something
like
> the following:
> 
> all.list=alist,blist,clist
> 
> alist=a,b,c
> blist=d,e,f
> clist=g,h,j
> 
> <foreach param="sublist.name" list="alist" target="foo"/>
> 
> <target name="foo">
>   <foreach param="component.name" list="${sublist.name}"
target="bar"/>
> </target>
> 
> <target name="bar">
>   <echo message="Project: ${sublist.name} Component:
${component.name}/>
> </target>

Maybe this contrived example of the powers of Ant-Contrib's <ac:for>
will help you find a solution to your unusual situation. --DD

PS: <ac:for> seems a bit limited in how it delimit the tokens of the
    List, so put just the delimiter in between them without spaces.
    (Now that I know of String.split(regex) in JDK 1.4, anything less
    powerful is disappointing ;-)

D:\org_apache\antx>D:\com_lgc\cycle9\buildtools\ant\bin\ant -f
listOfLists.xml
Buildfile: listOfLists.xml
     [echo] project: aap, element: all:
     [echo] project: aap, element: python
     [echo] project: ant, element: <target>
     [echo] project: ant, element: xml
     [echo] project: maven, element: <goal>
     [echo] project: maven, element: jelly

BUILD SUCCESSFUL
Total time: 0 seconds
D:\org_apache\antx>type listOfLists.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:ac="antlib:net.sf.antcontrib">
  <property name="projects" value="aap,ant,maven" />

  <property name="aap" value="all:,python" />
  <property name="ant" value="&lt;target&gt;,xml" />
  <property name="maven" value="&lt;goal&gt;,jelly" />

  <ac:for list="${projects}" param="project">
    <sequential>
      <ac:for list="${@{project}}" param="element">
        <sequential>
          <echo>project: @{project}; element: @{element}</echo>
        </sequential>
      </ac:for>
    </sequential>
  </ac:for>
</project>

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


Mime
View raw message