Ant dirset that includes the root directory

2.4k views Asked by At

How can I define a dirset in Ant, which includes two directories: the project's base directory, and a subdirectory "test"?

It looks like you can't specifically include the root directory of the dirset, using either "/", ".", or "". For example, this includes "./test", but not ".":

<dirset dir="." id="myDirs">
    <include name="." />
    <include name="test" />
</dirset>
2

There are 2 answers

2
bmargulies On

That is not obviously meaningful. Once the root is in, the test subdirectory is included with everything else. Maybe you need to tell us what is going to consume this dirset and what you expect it to do? Process 'test' twice?

Based on your comment, you need to add the root, and then add 'exclude' elements for everything in the root except test.

Or make two dirsets: one with the root excluding all the children, and another with just test.

0
David Charypar On

The documentation of DirSet doesn't explain this behavior but the following works properly on my Ubuntu 15.04 with ant version 1.9.4

<path id="my.two.dirs">
    <dirset dir="." id="myDirs1" excludes="*/**" />
    <dirset dir="." id="myDirs2" includes="test" />
</path>

This is pretty much what bmargulies posted in his answer, but since I didnt' understand it at first I thought a code example might be useful.