Sample Using Ant -Contrib Tasks
<taskdef resource="net/sf/antcontrib/antlib.xml"/> <target name="test_split"> <property name="prop" value="a,b,c"/> <for list="${prop}" param="letter"> <sequential> <echo>@{letter}</echo> </sequential> </for> </target>
Output:
a
b
c
Another solution from here :
<scriptdef name="split" language="javascript"> <attribute name="value"/> <attribute name="delimiter"/> <attribute name="prefix"/> <![CDATA[ values = attributes.get("value").split(attributes.get("delimiter")); for(i=0; i<values.length; i++) { project.setNewProperty(attributes.get("prefix")+i, values[i]); } ]]> </scriptdef> <target name="test_split2"> <property name="prop" value="a,b,c"/> <property name="prefix_str" value="Line_"/> <split value="${prop}" delimiter="," prefix="${prefix_str}"/> <echoproperties prefix="${prefix_str}"/> </target>
Output:
Ant properties
Tue Nov 22 17:12:55 2011
Line_0 = a
Line_1 = b
Line_2 = s
source share