Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant - Java - zipfileset - excluding a directory

Tags:

java

zip

ant

I have an ant target for creating zip like this -

<zip destfile="${dist}/myzip.zip">
    <zipfileset dir="docs/manual" prefix="docs/userguide"/>    
</zip>

This basically creates archive myzip.zip with all the files and directories under docs/manual prefixed with docs/userguide in the archive.

But I don' want to include all the directories under docs/manual to be copied into the archive, I have a directory called old under docs/manual which I want to exclude...How to achieve this?

like image 222
Johnbabu Koppolu Avatar asked Nov 22 '10 12:11

Johnbabu Koppolu


2 Answers

From the ZipFileSet reference page

<zipfileset> supports all attributes of <fileset> in addition to those listed below.

So see FileSet for reference.

This is how you do it:

<zipfileset dir="docs/manual" prefix="docs/userguide">    
    <exclude name="old/**"/>
</zipfileset>

or inline as attribute:

<zipfileset dir="docs/manual" prefix="docs/userguide" exclude="old/**" />

Update: Using wildcards now instead of simple name.

like image 119
Sean Patrick Floyd Avatar answered Sep 23 '22 12:09

Sean Patrick Floyd


you can exclude an entire directory by this:

<zipfileset dir="docs/manual" prefix="docs/userguide" exlcudes="**/old/**"/>
like image 43
carfieldba Avatar answered Sep 22 '22 12:09

carfieldba