Concepts and Types - TypesZipFileSetZipFileSetA <zipfileset> is a special form of a <fileset> which can behave in 2different ways :
- When the src attribute is used - or a nested resource collection has been specified (since Apache Ant 1.7), the zipfileset is populated with zip entries found in the file src.
- When the dir attributeis used, the zipfileset is populated with filesystem files found under dir.
<zipfileset> supports all attributes of <fileset> in addition to those listed below.
Since Ant 1.6, a zipfileset can be defined with the id attribute and referred to withthe refid attribute.
Parameters Attribute | Description | Required | prefix | all files in the fileset are prefixed with that path in the archive. | No | fullpath | the file described by the fileset is placed at that exact location in the archive. | No | src | may be used in place of the dir attribute to specify a zip file whose contents will be extracted and includedin the archive. | No | filemode | A 3 digit octal string, specify the user, group and other modes in the standard Unix fashion. Only applies to plain files. Default is 644. since Ant 1.5.2. | No | dirmode | A 3 digit octal string, specify the user, group and other modes in the standard Unix fashion. Only applies to directories. Default is 755. since Ant 1.5.2. | No | encoding | The character encoding to use for filenames inside the zip file. For a list of possible values see http://download.oracle.com/javase/1.5.0/docs/guide/intl/encoding.doc.html. Defaults to the platform's default character encoding. Only supported by zipfileset. | No | erroronmissingarchive | Specify what happens if the archive does not exist. If true, a build error will happen; if false, the fileset will be ignored/empty. Defaults to true. Since Ant 1.8.0 | No | The fullpath attribute can only be set for filesets thatrepresent a single file. The prefix and fullpathattributes cannot both be set on the same fileset. When using the src attribute, include and exclude patternsmay be used to specify a subset of the archive for inclusion in thearchive as with the dir attribute. Please note that currently only the tar and zip tasks use the permission. Parameters specified as nested elementsany file system based resource orsingle element resource collectionThe specified resource will be used as src. Examples <zip destfile="${dist}/manual.zip"> <zipfileset dir="htdocs/manual" prefix="docs/user-guide"/> <zipfileset dir="." includes="ChangeLog27.txt" fullpath="docs/ChangeLog.txt"/> <zipfileset src="examples.zip" includes="**/*.html" prefix="docs/examples"/> </zip>
zips all files in the htdocs/manual directory intothe docs/user-guide directory in the archive, adds thefile ChangeLog27.txt in the current directory as docs/ChangeLog.txt ,and includes all the html files in examples.zip under docs/examples .The archive might end up containing the files: docs/user-guide/html/index.html docs/ChangeLog.txt docs/examples/index.html |