ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject AW: Multiple properties into one property key
Date Wed, 19 May 2010 05:32:16 GMT
This works for me:

<project xmlns:ac="antlib:net.sf.antcontrib">

    <macrodef name="values2list">
        <attribute name="property"/>
        <attribute name="prefix"/>
        <attribute name="size"/>
        <attribute name="separator" default=","/>
            <ac:var name="@{property}" value="${@{prefix}1}"/>
            <ac:for param="nr" begin="2" end="@{size}">
                    <ac:var name="@{property}" value="${@{property}}@{separator}${@{prefix}@{nr}}"/>

    <property name="name.1" value="foo"/>
    <property name="name.2" value="foo"/>
    <property name="name.3" value="abc"/>
    <property name="name.4" value="xyz"/>

    <values2list property="list" prefix="name." size="4"/>

    <echo>List: ${list}</echo>


>-----Urspr√ľngliche Nachricht-----
>Von: Jan [] 
>Gesendet: Mittwoch, 19. Mai 2010 06:41
>An: Ant Users List
>Betreff: Multiple properties into one property key
>Hi All,
>I'm trying to read muliple properties into one property key is 
>that possible
>int ant?
>For examble lets say i property file called in 
>that i've
>entries as shown below
>now i want read these 2 property key value and assign to property
>allNames=${name1},${name2}.....${namen}, coz i will know the value of
>"numberofnames" only at runtime i used ant-contrib 1.0b3 like below
>  <for param="num" end="${numberofnames}">
>   <sequential>
>    <if>
>     <equals arg1="@{num}" arg2="0"/>
>     <then>
>      <echo message="XXXXX Skipping the as ant contrib start 
>with value "0"
>and there won't be any property like "name0" will be available"
>     </then>
>     <else>
>      <propertycopy name="name"        from="name@{num}"
>         <echo file="props.ext">${name}${line.separator}</echo>
>         <loadfile srcfile="props.ext" property="${nameList}">
>           <filterchain>
>             <filterreader
>               <param name="lines" value="${numberofnames}"/>
>             </filterreader>
>           </filterchain>
>         </loadfile>
>     </else>
>    </if>
>   </sequential>
>  </for>
>This does stores all name1 and name2 value into props.ext 
>file,  but when i
>tried ito read the file usine "loadfile" its just prints the 
>name1 only not
>Thanks in advance for your help

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message