ant fileset dir exclude certain directory

ant

Solution

I think it should probably be:

<copy todir="${dir.classes}">
<fileset dir="${dir.src}" >
  <exclude name="**/*.java"/>
  <exclude name="**/A-dir/**/B-dir/**"/>
</fileset>
</copy>

Note the `**/A-dir/**` instead of `A-dir/**`.

Problem

There are many questions on this topic but none of the answers are solving my problem. Starting this thread again to get fresh input. I tried two different approaches for excluding B-dir and all its contents under A-dir/subdir. But none work. FYI, a-dir is under dir.src 1) ``` <copy todir="${dir.classes}" excludes="A-dir/**/B-dir/**"> <fileset dir="${dir.src}" > <exclude name="**/*.java"/> </fileset> </copy> ``` 2) ``` <copy todir="${dir.classes}"> <fileset dir="${dir.src}" > <exclude name="**/*.java"/> <exclude name="A-dir/**/B-dir/**"/> </fileset> </copy> ``` I tried deleting all old jars and do a clean compile like someone suggested. But that doesn't help either.

Original source