views:

400

answers:

1

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>
+1  A: 

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.

bmargulies
I want to loop over the dirset using ant-contrib's foreach, and create a file in each directory (e.g. I'll create ./file and ./test/file). I don't think that including a particular dir necessarily includes its children, unless you append "/" or "/**".
JW
Hmm...I won't necessarily know the names of the non-"test" directories in advance. It's too bad -- I can include, for example, "test" and "test/foo", and it will only use those two directories, not "test/bar". But this doesn't work at the root level.
JW