In an Ant task I set a property which is a list of files. e.g.
web/src/main/test/com/whatever/Ralph
business/src/main/test/com/whatever/Alice
web/src/main/test/com/whatever/Bob
I would like to extract the set of subdirectories from this list. In bash I'd:
$ cat filename | cut -d'/' -f1 | sort | uniq
business
web
Is there a way I can do something similar in an Ant macro? It needs to run on Windows too, so <exec>
is not an option.
You can do this using a
loadresource
task with a filterchain. Something like this perhaps:Result:
In older versions of Ant (<1.7) you could do the same by writing the property out to a file, then using a
loadfile
task with filterchain.