90
Apache Ant Zip Task
Ant Zip task is used to create zip file. basedir attribute is used to refer source of files from where zip file is created. We can use exclude attribute to exclude the file from being zipped.
It makes a implicit fileset and supports various nested elements including <fileset>, <include>, <exclude> and <patternset>.
Apache Ant Zip Task Attributes
Attribute | Description | Required |
---|---|---|
destfile | Name of zip file to be created. | Yes |
basedir | the directory from which to zip the files. | No |
compress | Store and compress data as well. | No |
encoding | The character encoding to use for filenames inside the zip file. | No |
filesonly | It is used to store files entries only. | No |
includes | A list of file to be include. | No |
excludes | A list of files that must be excluded. | No |
update | Update the destination file if it is already exists. | No |
whenempty | behavior when no files match. Valid values are fail, skip, and create. | No |
duplicate | behavior when a duplicate file is found. | No |
comment | Comment to store in the archive. | No |
level | Non-default level at which file compression should be performed. | No |
fallbacktoUTF8 | Whether to use UTF-8 and the language encoding flag instead of the specified encoding. | No |
zip64Mode | When to use Zip64 extensions for entries. | No |
Let’s see some examples to create a zipfile.
Apache Ant Zip Task Example
Create a zip file manual.zip by collecting all the files from tutoraspir/java directory.
If zip file exist, it update zip file.
We can exclude file by specifying names of files using excludes attribute.
Next TopicApache Ant JUnit Task