I am using the jar
task in ant and wish to exclude a certain directory. The structure of the directories is something like:
food
|_ fruits
|_ apples
|_ bananas
(having been made generic and simplified a little)
And I have an ant task like this:
<jar destfile="Dest.jar">
...
<fileset dir="food">
<exclude name="**/bananas/" />
<exclude name="**/*Test*" />
<include name="**/*.class" />
</fileset>
...
What I am trying to do is:
- include all files which end in ".class" (this works)
- exclude all files which have "Test" in their file name (this works)
- exclude an entire directory named "bananas" (this doesn't work)
I have tried several combinations of wildcards in trying to exclude the bananas directory, to no avail. I have also tried reordering the include and excludes, though I have no idea if that makes a difference. I've also tried a couple of other suggestions[1][2] which didn't do the job. My wild guess at the moment is that within the bananas directory, there are files which match "*.class", so I'm thinking their inclusion is preventing bananas from being excluded.
NB: I'm matching the real name of the bananas directory exactly, so case-sensitivity shouldn't be an issue. If it can make the task simpler, I can reference the full path to the directory, though I'd prefer to be a bit more refactor-friendly in the ant task.
How can I exclude a directory which is already included in an ant fileset?
[1] http://www.velocityreviews.com/forums/t146608-in-ant-how-do-you-exclude-a-directory-from-copy-or-zip.html
[2] Ant/filesetwithexclude.htm">http://www.java2s.com/Tutorial/Java/0520_Ant/filesetwithexclude.htm