Currently, if a top-level directory is included in the Zip/Tar task, the full contents of this directory will be added to the Zip/Tar.
Assuming the following basic filesystem structure:
- testdir/
- include.txt
- include2.txt
Here is an example buildfile that produces unexpected results:
<project name="foo" default="build">
<target name="build">
<delete file="test.tgz"/>
<delete file="test.zip"/>
<fileset dir="." id="archive.files">
<include name="testdir"/>
<include name="include*.txt"/>
<exclude name="testdir/CVS"/>
</fileset>
<tar destfile="test.tgz" compression="gzip">
<fileset refid="archive.files"/>
</tar>
<zip destfile="test.zip">
<fileset refid="archive.files"/>
</zip>
</target>
</project>
The unexpected result is that testdir/CVS will be included, despite being explicitly excluded. This is due to the way that file/dir additions are processed by the underlying zip/tar libraries.
One workaround currently would be to define the fileset as such:
<fileset dir="." id="archive.files">
<include name="testdir/**"/> <!-- NOTE DIFFERENCE -->
<include name="include*.txt"/>
<exclude name="testdir/CVS"/>
</fileset>