views:

29

answers:

1

How can one test to see that a directory is empty in ant?

+1  A: 

You can use the pathconvert task to do that, with the setonempty property. See ">this example for an use case.

<pathconvert refid="myfileset"
             property="fileset.notempty"
             setonempty="false"/>

will set the property fileset.notempty only if the fileset those refid is myfileset is not empty.

You just have to define myfileset with your directory, and no excludes do get a directory empty test:

<fileset dir="foo/bar" id="myfileset"/>
tonio