Convert Property to Path

I have a comma-separated value property, for example. a B C

I want to break it into pieces and create a path to different sets of files; eg.

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

Is it possible? How should I do it? I am not very familiar with ant. Any help was appreciated.

+3
source share
3 answers

You will have to use a custom script or custom Ant task. Check out this SO answer that explains how to get the form of a substring of a property to get you started.

0
source

Another way to write a for loop is to loop through the original property based on seperator and call the 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>   
0
source

- PropertySelector 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
0

All Articles