3

I have an ant target for creating zip like this -

<zip destfile="${dist}/myzip.zip">
    <zipfileset prefix="product/install" includes="docs/resources/**,docs/*.*" excludes="docs/build.bat,docs/*.xml,docs/resources/*.html"/>
</zip>

Now, how do I ensure that empty directories don't get included in this zipfileset.

Eg: docs/resources directory only has html files, all of which I have excluded above. How do I make sure docs/resources folder doesn't get included.

Should I be checking for this manually everytime? or is there an option like includeEmptyDirs="false"?

gturri
  • 13,807
  • 9
  • 40
  • 57
darkraven
  • 61
  • 1
  • 1
  • 7

1 Answers1

3

I think there isn't an option for this in zip task, see documentation.

But what you can do is to make a copy with excludes/includes, and define to exclude the empty directories and then call the zip task on the copied folder:

<copy todir="tmp2" includeEmptyDirs="false">
    <fileset dir="tmp1" excludes="**/*.txt"/>
</copy>
<zip>...

Documentation of copy

cy3er
  • 1,699
  • 11
  • 14