3

I have a property of comma seperated values, eg. a,b,c

I want to break this apart and create a path of different filesets; eg.

<path id="compile.path">
  <fileset dir="..\a\lib\"/>
  <fileset dir="..\b\lib\"/>
  <fileset dir="..\c\lib\"/>
</path>

Is this possible? How do I do it? I'm not very familiar with ant. Any help appreciated.

Brett Walker
  • 3,566
  • 1
  • 18
  • 36

3 Answers3

0

You'll have to use a custom script or a non-standard Ant task. Have a look at this SO answer which explains how to get a substring form a property to get you started.

Community
  • 1
  • 1
gareth_bowles
  • 20,760
  • 5
  • 52
  • 82
0

Another way write a for loop, iterate the original property based on a seperator and call a target from the loop for each token.

    <foreach list="${property}" delimiter="${line.separator}" target="mytarget" 
param="token" />

Then the called target:

<target name="mytarget">
    <echo>${token}</echo>           
</target>   
Pulak Agrawal
  • 2,481
  • 4
  • 25
  • 49
0

Another way is to use PropertySelector from ant-contrib

    <property name="package.ABC.name" value="abc pack name" />
    <property name="package.DEF.name" value="def pack name" />
    <property name="package.GHI.name" value="ghi pack name" />
    <property name="package.JKL.name" value="jkl pack name" />

    <propertyselector property="pack.list"
                         delimiter=","
                         match="package\.([^\.]*)\.name"
                         select="\1"
                         casesensitive="false" />               
would yield the results  
ABC,DEF,GHI,JKL
Pulak Agrawal
  • 2,481
  • 4
  • 25
  • 49
  • This didn't satisfy my requirements as it uses one or more properties to create another property. I need a path element. – Brett Walker May 18 '12 at 08:30