| 1 |
<!DOCTYPE html> |
| 2 |
<!-- |
| 3 |
Licensed to the Apache Software Foundation (ASF) under one or more |
| 4 |
contributor license agreements. See the NOTICE file distributed with |
| 5 |
this work for additional information regarding copyright ownership. |
| 6 |
The ASF licenses this file to You under the Apache License, Version 2.0 |
| 7 |
(the "License"); you may not use this file except in compliance with |
| 8 |
the License. You may obtain a copy of the License at |
| 9 |
|
| 10 |
https://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
|
| 12 |
Unless required by applicable law or agreed to in writing, software |
| 13 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 14 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 |
See the License for the specific language governing permissions and |
| 16 |
limitations under the License. |
| 17 |
--> |
| 18 |
<html lang="en"> |
| 19 |
<head> |
| 20 |
<link rel="stylesheet" type="text/css" href="../stylesheets/style.css"> |
| 21 |
<title>ZipFileSet Type</title> |
| 22 |
</head> |
| 23 |
<body> |
| 24 |
<h2 id="fileset">ZipFileSet</h2> |
| 25 |
|
| 26 |
<p>A <code><zipfileset></code> is a special form of |
| 27 |
a <code><<a href="fileset.html">fileset</a>></code> which can behave in 2 different ways:</p> |
| 28 |
<ul> |
| 29 |
<li>When the <var>src</var> attribute is used—or a nested resource collection has been |
| 30 |
specified (<em>since Apache Ant 1.7</em>), the zipfileset is populated with zip entries found in |
| 31 |
the file <var>src</var>.</li> |
| 32 |
<li>When the <var>dir</var> attribute is used, the zipfileset is populated with filesystem files |
| 33 |
found under <var>dir</var>.</li> |
| 34 |
</ul> |
| 35 |
<p><code><zipfileset></code> supports all attributes |
| 36 |
of <code><<a href="fileset.html">fileset</a>></code> in addition to those listed below. Note |
| 37 |
that zip archives in general don't contain entries with leading slashes so you shouldn't |
| 38 |
use <var>includes</var>/<var>excludes</var> patterns that start with slashes either.</p> |
| 39 |
|
| 40 |
<p><em>Since Ant 1.6</em>, a zipfileset can be defined with the <var>id</var> attribute and referred |
| 41 |
to with the <var>refid</var> attribute.</p> |
| 42 |
|
| 43 |
<h3>Parameters</h3> |
| 44 |
<table class="attr"> |
| 45 |
<tbody> |
| 46 |
<tr> |
| 47 |
<th scope="col">Attribute</th> |
| 48 |
<th scope="col">Description</th> |
| 49 |
<th scope="col">Required</th> |
| 50 |
</tr> |
| 51 |
<tr> |
| 52 |
<td>prefix</td> |
| 53 |
<td>all files in the fileset are prefixed with that path in the archive.</td> |
| 54 |
<td>No</td> |
| 55 |
</tr> |
| 56 |
<tr> |
| 57 |
<td>fullpath</td> |
| 58 |
<td>the file described by the fileset is placed at that exact location in the archive.</td> |
| 59 |
<td>No</td> |
| 60 |
</tr> |
| 61 |
<tr> |
| 62 |
<td>src</td> |
| 63 |
<td>may be used in place of the <var>dir</var> attribute to specify a zip file whose contents |
| 64 |
will be extracted and included in the archive.</td> |
| 65 |
<td>No</td> |
| 66 |
</tr> |
| 67 |
<tr> |
| 68 |
<td>filemode</td> |
| 69 |
<td>A 3 digit octal string, specify the user, group and other modes in the standard Unix |
| 70 |
fashion. Only applies to plain files. <em>Since Ant 1.5.2</em></td> |
| 71 |
<td>No; default is <q>644</q></td> |
| 72 |
</tr> |
| 73 |
<tr> |
| 74 |
<td>dirmode</td> |
| 75 |
<td>A 3 digit octal string, specify the user, group and other modes in the standard Unix |
| 76 |
fashion. Only applies to directories. <em>Since Ant 1.5.2</em></td> |
| 77 |
<td>No; default is <q>755</q></td> |
| 78 |
</tr> |
| 79 |
<tr> |
| 80 |
<td>encoding</td> |
| 81 |
<td>The character encoding to use for filenames inside the zip file. For a list of possible |
| 82 |
values see |
| 83 |
the <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html" |
| 84 |
target="_top">Supported Encodings</a>. |
| 85 |
<td>No; defaults to default JVM character encoding</td> |
| 86 |
</tr> |
| 87 |
<tr> |
| 88 |
<td>erroronmissingarchive</td> |
| 89 |
<td>Specify what happens if the archive does not exist. If <q>true</q>, a build error will |
| 90 |
happen; if <q>false</q>, the fileset will be ignored/empty. <em>Since Ant 1.8.0</em></td> |
| 91 |
<td>No; defaults to <q>true</q></td> |
| 92 |
</tr> |
| 93 |
</tbody> |
| 94 |
</table> |
| 95 |
<p>The <var>fullpath</var> attribute can only be set for filesets that represent a single |
| 96 |
file. The <var>prefix</var> and <var>fullpath</var> attributes cannot both be set on the same |
| 97 |
fileset.</p> |
| 98 |
<p>When using the <var>src</var> attribute, <var>includes</var> and <var>excludes</var> patterns |
| 99 |
may be used to specify a subset of the archive for inclusion in the archive as with |
| 100 |
the <var>dir</var> attribute.</p> |
| 101 |
|
| 102 |
<p>Please note that currently only the <a href="../Tasks/tar.html">tar</a> |
| 103 |
and <a href="../Tasks/zip.html">zip</a> tasks use the permission.</p> |
| 104 |
|
| 105 |
<h3>Parameters specified as nested elements</h3> |
| 106 |
|
| 107 |
<h4>any file system based <a href="resources.html">resource</a> or single element resource |
| 108 |
collection</h4> |
| 109 |
|
| 110 |
<p>The specified resource will be used as <var>src</var>.</p> |
| 111 |
|
| 112 |
<h4>Examples</h4> |
| 113 |
<pre> |
| 114 |
<zip destfile="${dist}/manual.zip"> |
| 115 |
<zipfileset dir="htdocs/manual" prefix="docs/user-guide"/> |
| 116 |
<zipfileset dir="." includes="ChangeLog27.txt" fullpath="docs/ChangeLog.txt"/> |
| 117 |
<zipfileset src="examples.zip" includes="**/*.html" prefix="docs/examples"/> |
| 118 |
</zip></pre> |
| 119 |
<p>zips all files in the <samp>htdocs/manual</samp> directory into |
| 120 |
the <samp>docs/user-guide</samp> directory in the archive, adds the |
| 121 |
file <samp>ChangeLog27.txt</samp> in the current directory as <samp>docs/ChangeLog.txt</samp>, |
| 122 |
and includes all the html files in <samp>examples.zip</samp> under <samp>docs/examples</samp>. |
| 123 |
The archive might end up containing the files:</p> |
| 124 |
<pre>docs/user-guide/html/index.html |
| 125 |
docs/ChangeLog.txt |
| 126 |
docs/examples/index.html</pre> |
| 127 |
|
| 128 |
</body> |
| 129 |
</html> |