Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Define a list or a set of variables in ant

I'd like to define a list of variables in ant build file in order to use for loop with this list in my tasks. How can I do that?

p.s.: It should be something like the following:

<varlist name="mylist"> <!-- Actually, there is no such tag in Ant -->
    <item>someThing</item>
    <item>anotherThing</item>
</varlist>

...

<for param="item" list="${mylist}">
    <sequential>
        <echo>@{item}</echo>
    </sequential>
</for>
like image 667
tsds Avatar asked Feb 21 '23 22:02

tsds


2 Answers

<!-- "For" task is supported by Ant-Contrib Tasks 
http://ant-contrib.sourceforge.net/tasks/tasks/index.html -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
  <classpath>
    <pathelement location="ant-contrib-1.0b3.jar"/>
  </classpath>
</taskdef>

<property name="someThing" value="Hello"/>
<property name="anotherThing" value="World!"/>

<target name="loop">
    <for param="item" list="${someThing},${anotherThing}">
        <sequential>
            <echo>@{item}</echo>
        </sequential>
    </for>
</target>
like image 199
splash Avatar answered Feb 26 '23 08:02

splash


Not sure if this is what you meant:

<echo message="The first five letters of the alphabet are:"/>
<for list="a,b,c,d,e" param="letter">
  <sequential>
    <echo>Letter @{letter}</echo>
  </sequential>
</for>
like image 41
Anonymous Avatar answered Feb 26 '23 07:02

Anonymous