Ant: use include and exclude together

Posted by Ken on Stack Overflow See other posts from Stack Overflow or by Ken
Published on 2011-01-07T19:35:01Z Indexed on 2011/01/07 19:53 UTC
Read the original article Hit count: 255

Filed under:
|
|
|

OK, this seems like it should be really simple. I'm using Apache Ant 1.8, and I have a target which does:

<delete file="output/program.tar.bz2"/>
<tar basedir="input" destfile="output/program.tar.bz2" compression="bzip2">
  <tarfileset dir="input">
    <include name="goodfolder1/**"/>
    <include name="goodfolder2/**"/>
    <exclude name="**/badfile"/>
    <exclude name="**/*.badext"/>
  </tarfileset>
</tar>

I want it to make a .tar.bz2 of input/goodfolder1 and input/goodfolder2, excluding files named "badfile", and excluding files with extension ".badext". It's giving me a .tar.bz2, but it's including badfile and *.badext -- the excludes seem to be ignored.

The order of include/exclude doesn't seem to make a difference. I tried wrapping the includes/excludes in a (the docs say it's implicit?), but it made no difference.

I'm sure there's something simple I'm missing, since the manual has a very similar example, though in a somewhat different context.

EDIT: It looks like it could be related to the dir="input" attribute: it's adding everything in "input", and then adding everything in the tarfileset to that. Files I want appear twice in the program.tar.bz2, but files that are excluded only appear once. But dir is mandatory, and I don't see how this is different from the examples in the manual.

© Stack Overflow or respective owner

Related posts about ant

Related posts about include