Ant read files in a directory and regex
I am trying to read the names of a set of files in a directory and apply
regex to those names and obtain a list with comma seperated values. The
names of the files are in the format of build_level1_D1.properties,
build_level1.D2.properties, build_level2.D1.properties etc... I need to
read all the file names and apply regex and parse the names to get
level1_D1, level1_D2, level2_D1 etc.. I need it in the format of This is
what i tried. Need some pointers and help.
<target name="build-all">
<fileset id="appendLevels" dir="${root.build.path}/build">
<include name="*" />
</fileset>
<property name="dist.contents" refid="appendLevels" />
<echo>${dist.contents}</echo>
<-- This gives me a list of all files. I then am trying to use a for to
loop through each filename and regex it.----->
<for list="${dist.contents}" delimiter=";" param="build.regex">
<sequential>
<propertyregex property="filenamelevel.modified"
input="${dist.contents}" regexp="build\_([^\.]*)" select="\1">
</propertyregex>
</sequential>
</for>
<property name="build.levels" value="${filenamelevel.modified}" />
<-- This is just giving me the first value level1_D1 but i need it lin the
format of <property name="build.levels"
value="level1_D1,level1_D2,level2_D1" />
</target>
No comments:
Post a Comment