You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

zip.html 25 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. <!--
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <html>
  16. <head>
  17. <meta http-equiv="Content-Language" content="en-us">
  18. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  19. <title>Zip Task</title>
  20. </head>
  21. <body>
  22. <h2 id="zip">Zip</h2>
  23. <h3>Description</h3>
  24. <p>Creates a zipfile.</p>
  25. <p>The <var>basedir</var> attribute is the reference directory from where to zip.</p>
  26. <p>Note that file permissions will not be stored in the resulting zipfile.</p>
  27. <p>It is possible to refine the set of files that are being zipped. This can be done with
  28. the <var>includes</var>, <var>includesfile</var>, <var>excludes</var>, <var>excludesfile</var>
  29. and <var>defaultexcludes</var> attributes. With the <var>includes</var> or <var>includesfile</var>
  30. attribute you specify the files you want to have included by using patterns. The <var>exclude</var>
  31. or <var>excludesfile</var> attribute is used to specify the files you want to have excluded. This is
  32. also done with patterns. And finally with the <var>defaultexcludes</var> attribute, you can specify
  33. whether you want to use default exclusions or not. See the section
  34. on <a href="../dirtasks.html#directorybasedtasks">directory based tasks</a>, on how the
  35. inclusion/exclusion of files works, and how to write patterns.</p>
  36. <p>This task forms an implicit <a href="../Types/fileset.html">FileSet</a> and supports most
  37. attributes of <code>&lt;fileset&gt;</code> (<var>dir</var> becomes <var>basedir</var>) as well as
  38. the nested <code>&lt;include&gt;</code>, <code>&lt;exclude&gt;</code>
  39. and <code>&lt;patternset&gt;</code> elements.</p>
  40. <p>Or, you may place within it nested file sets, or references to file sets. In this
  41. case <var>basedir</var> is optional; the implicit file set is <em>only used</em>
  42. if <var>basedir</var> is set. You may use any mixture of the implicit file set
  43. (with <var>basedir</var> set, and optional attributes like <var>includes</var> and optional
  44. subelements like <code>&lt;include&gt;</code>); explicit nested <code>&lt;fileset&gt;</code>
  45. elements so long as at least one fileset total is specified. The ZIP file will only reflect the
  46. relative paths of files <em>within</em> each fileset. The Zip task and its derivatives know a
  47. special form of a fileset named <code>zipfileset</code> that has additional attributes (described
  48. below).</p>
  49. <p>The Zip task also supports the merging of multiple zip files into the zip file. This is possible
  50. through either the <var>src</var> attribute of any nested filesets or by using the special nested
  51. fileset <code>zipgroupfileset</code>.</p>
  52. <p>The <var>update</var> parameter controls what happens if the ZIP file already exists. When set
  53. to <q>yes</q>, the ZIP file is updated with the files specified. (New files are added; old files are
  54. replaced with the new versions.) When set to <q>no</q> (the default) the ZIP file is overwritten if
  55. any of the files that would be added to the archive are newer than the entries inside the archive.
  56. Please note that ZIP files store file modification times with a granularity of 2 seconds. If a file
  57. is less than 2 seconds newer than the entry in the archive, Apache Ant will not consider it
  58. newer.</p>
  59. <p>The <var>whenempty</var> parameter controls what happens when no files match. If <q>skip</q>
  60. (the default), the ZIP is not created and a warning is issued. If <q>fail</q>, the ZIP is not
  61. created and the build is halted with an error. If <q>create</q>, an empty ZIP file (explicitly zero
  62. entries) is created, which should be recognized as such by compliant ZIP manipulation tools.</p>
  63. <p>This task will now use default JVM character encoding for filenames&mdash;this is consistent with
  64. the command line ZIP tools, but causes problems if you try to open them from within Java and your
  65. filenames contain non US-ASCII characters. Use the <var>encoding</var> attribute and set it
  66. to <q>UTF8</q> to create zip files that can safely be read by Java. For a more complete discussion,
  67. see <a href="#encoding">below</a></p>
  68. <p><em>Since Ant 1.5.2</em>, <code>&lt;zip&gt;</code> can store Unix permissions inside the archive
  69. (see description of the <var>filemode</var> and <var>dirmode</var> attributes
  70. for <a href="../Types/zipfileset.html">&lt;zipfileset&gt;</a>). Unfortunately there is no portable
  71. way to store these permissions. Ant uses the algorithm used by <a href="http://www.info-zip.org"
  72. target="_top">Info-Zip's</a> implementation of the <kbd>zip</kbd> and <kbd>unzip</kbd>
  73. commands&mdash;these are the default versions of <kbd>zip</kbd> and <kbd>unzip</kbd> for many
  74. Unix(-like) systems.</p>
  75. <p><strong>Please note that the zip format allows multiple files of the same fully-qualified name to
  76. exist within a single archive. This has been documented as causing various problems for
  77. unsuspecting users. If you wish to avoid this behavior you must set the <var>duplicate</var>
  78. attribute to a value other than its default, <q>add</q>.</strong></p>
  79. <p><strong>Please also note</strong> that different ZIP tools handle timestamps differently when it
  80. comes to applying timezone offset calculations of files. Some ZIP libraries will store the
  81. timestamps as they've been read from the filesystem while others will modify the timestamps both
  82. when reading and writing the files to make all timestamps use the same timezone. A ZIP archive
  83. created by one library may extract files with "wrong timestamps" when extracted by another
  84. library.</p>
  85. <p>Ant's ZIP classes use the same algorithm as the InfoZIP tools and zlib (timestamps get adjusted),
  86. Windows' "compressed folders" function and WinZIP don't change the timestamps. This means that
  87. using the <code>unzip</code> task on files created by Windows' compressed folders function may
  88. create files with timestamps that are "wrong", the same is true if you use Windows' functions to
  89. extract an Ant generated ZIP archive.</p>
  90. <h3>Parameters</h3>
  91. <table class="attr">
  92. <tr>
  93. <th scope="col">Attribute</th>
  94. <th scope="col">Description</th>
  95. <th scope="col">Required</th>
  96. </tr>
  97. <tr>
  98. <td>destfile</td>
  99. <td>the zip file to create.</td>
  100. <td rowspan="2">Exactly one of the two</td>
  101. </tr>
  102. <tr>
  103. <td>zipfile</td>
  104. <td class="left"><em><u>deprecated</u></em> old name of <var>destfile</var>.</td>
  105. </tr>
  106. <tr>
  107. <td>basedir</td>
  108. <td>the directory from which to zip the files.</td>
  109. <td>No</td>
  110. </tr>
  111. <tr>
  112. <td>compress</td>
  113. <td>Not only store data but also compress them. Unless you set the <var>keepcompression</var>
  114. attribute to <q>false</q>, this will apply to the entire archive, not only the files you've
  115. added while updating.</td>
  116. <td>No; defaults to <q>true</q></td>
  117. </tr>
  118. <tr>
  119. <td>keepcompression</td>
  120. <td>For entries coming from existing archives (like nested <code>zipfileset</code>s or while
  121. updating the archive), keep the compression as it has been originally instead of using
  122. the <var>compress</var> attribute. <em>Since Ant 1.6</em></td>
  123. <td>No; defaults to <q>false</q></td>
  124. </tr>
  125. <tr>
  126. <td>encoding</td>
  127. <td>The character encoding to use for filenames inside the zip file. For a list of possible
  128. values see
  129. the <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html"
  130. target="_top">Supported Encodings</a>.</td>
  131. <td>No; defaults to default JVM character encoding</td>
  132. </tr>
  133. <tr>
  134. <td>filesonly</td>
  135. <td>Store only file entries.</td>
  136. <td>No; defaults to <q>false</q></td>
  137. </tr>
  138. <tr>
  139. <td>includes</td>
  140. <td>comma- or space-separated list of patterns of files that must be included.</td>
  141. <td>No; defaults to all (<q>**</q>)</td>
  142. </tr>
  143. <tr>
  144. <td>includesfile</td>
  145. <td>name of a file. Each line of this file is taken to be an include pattern.</td>
  146. <td>No</td>
  147. </tr>
  148. <tr>
  149. <td>excludes</td>
  150. <td>comma- or space-separated list of patterns of files that must be excluded.</td>
  151. <td>No; defaults to default excludes or none if <var>defaultexcludes</var> is <q>no</q></td>
  152. </tr>
  153. <tr>
  154. <td>excludesfile</td>
  155. <td>name of a file. Each line of this file is taken to be an exclude pattern.</td>
  156. <td>No</td>
  157. </tr>
  158. <tr>
  159. <td>defaultexcludes</td>
  160. <td>indicates whether default excludes should be used or not (<q>yes|no</q>).</td>
  161. <td>No; defaults to <q>yes</q></td>
  162. </tr>
  163. <tr>
  164. <td>update</td>
  165. <td>indicates whether to update or overwrite the destination file if it already exists.</td>
  166. <td>No; default is <q>false</q></td>
  167. </tr>
  168. <tr>
  169. <td>whenempty</td>
  170. <td>behavior when no files match. Valid values are <q>fail</q>, <q>skip</q>,
  171. and <q>create</q>.</td>
  172. <td>No; default is <q>skip</q></td>
  173. </tr>
  174. <tr>
  175. <td>duplicate</td>
  176. <td>behavior when a duplicate file is found. Valid values are <q>add</q>, <q>preserve</q>,
  177. and <q>fail</q>.</td>
  178. <td>No; default is <q>add</q></td>
  179. </tr>
  180. <tr>
  181. <td>roundup</td>
  182. <td>Whether the file modification times will be rounded up to the next even number of
  183. seconds.<br/>Zip archives store file modification times with a granularity of 2 seconds, so
  184. the times will either be rounded up or down. If you round down, the archive will always seem
  185. out-of-date when you rerun the task, so the default is to round up. Rounding up may lead to a
  186. different type of problems like JSPs inside a web archive that seem to be slightly more recent
  187. than precompiled pages, rendering precompilation useless. <em>Since Ant 1.6.2</em></td>
  188. <td>No; defaults to <q>true</q></td>
  189. </tr>
  190. <tr>
  191. <td>comment</td>
  192. <td>Comment to store in the archive. <em>Since Ant 1.6.3</em></td>
  193. <td>No</td>
  194. </tr>
  195. <tr>
  196. <td>level</td>
  197. <td>Non-default level at which file compression should be performed. Valid values range
  198. from <q>0</q> (no compression/fastest) to <q>9</q> (maximum compression/slowest). <em>Since
  199. Ant 1.7</em></td>
  200. <td>No</td>
  201. </tr>
  202. <tr>
  203. <td>preserve0permissions</td>
  204. <td>when updating an archive or adding entries from a different archive Ant will assume that a
  205. Unix permissions value of 0 (nobody is allowed to do anything to the file/directory) means
  206. that the permissions haven't been stored at all rather than real permissions and will instead
  207. apply its own default values.<br/> Set this attribute to <q>true</q> if you really want to
  208. preserve the original permission field. <em>Since Ant 1.8.0</em>
  209. </td>
  210. <td>No; default is <q>false</q></td>
  211. </tr>
  212. <tr>
  213. <td>useLanguageEncodingFlag</td>
  214. <td>Whether to set the language encoding flag if the encoding is UTF-8. This setting doesn't
  215. have any effect if the encoding is not UTF-8. <em>Since Ant 1.8.0</em>.<br/>See also
  216. the <a href="#encoding">discussion below</a></td>
  217. <td>No; default is <q>true</q></td>
  218. </tr>
  219. <tr>
  220. <td>createUnicodeExtraFields</td>
  221. <td>Whether to create Unicode extra fields to store the file names a second time inside the
  222. entry's metadata.<br/>Possible values are <q>never</q>, <q>always</q>
  223. and <q>not-encodeable</q> which will only add Unicode extra fields if the file name cannot be
  224. encoded using the specified encoding. <em>Since Ant 1.8.0</em>.<br/>See also
  225. the <a href="#encoding">discussion below</a></td>
  226. <td>No; default is <q>never</q></td>
  227. </tr>
  228. <tr>
  229. <td>fallbacktoUTF8</td>
  230. <td>Whether to use UTF-8 and the language encoding flag instead of the specified encoding if a
  231. file name cannot be encoded using the specified encoding. <em>Since Ant 1.8.0</em>.<br/>See
  232. also the <a href="#encoding">discussion below</a></td>
  233. <td>No; default is <q>false</q></td>
  234. </tr>
  235. <tr>
  236. <td>zip64Mode</td>
  237. <td>When to use Zip64 extensions for entries. The possible values
  238. are <q>never</q>, <q>always</q> and <q>as-needed</q>. <em>Since Ant 1.9.1</em>.<br/>See also
  239. the <a href="#zip64">discussion below</a></td>
  240. <td>No; default is <q>as-needed</q></td>
  241. </tr>
  242. </table>
  243. <h3 id="encoding">Encoding of file names</h3>
  244. <p>Traditionally the ZIP archive format uses CodePage 437 as encoding for file name, which is not
  245. sufficient for many international character sets.</p>
  246. <p>Over time different archivers have chosen different ways to work around the
  247. limitation&mdash;the <code class="code">java.util.zip</code> packages simply uses UTF-8 as its
  248. encoding for example.</p>
  249. <p>Ant has been offering the <q>encoding</q> attribute of the <code>zip</code>
  250. and <code>unzip</code> task as a way to explicitly specify the encoding to use (or expect) <em>since
  251. Ant 1.4</em>. It defaults to default JVM character encoding for <code>zip</code> and UTF-8
  252. for <code>jar</code> and other jar-like tasks (<code>war</code>, <code>ear</code>, ...) as well as
  253. the <code>unzip</code> family of tasks.</p>
  254. <p>More recent versions of the ZIP specification introduce something called the <q>language encoding
  255. flag</q> which can be used to signal that a file name has been encoded using UTF-8. <em>Since Ant
  256. 1.8.0</em>, all zip, jar and similar archives written by Ant will set this flag, if the encoding has
  257. been set to UTF-8. Our interoperability tests with existing archivers didn't show any ill effects
  258. (in fact, most archivers ignore the flag to date), but you can turn off the <q>language encoding
  259. flag</q> by setting the attribute <var>useLanguageEncodingFlag</var> to <q>false</q> on
  260. the <code>zip</code> task if you should encounter problems.</p>
  261. <p>The <code>unzip</code> task (and similar tasks) will recognize the language encoding flag and
  262. ignore the encoding set on the task if it has been found.</p>
  263. <p>The InfoZIP developers have introduced new ZIP extra fields that can be used to add an additional
  264. UTF-8 encoded file name to the entry's metadata. Most archivers ignore these extra
  265. fields. <em>Since Ant 1.8.0</em>, the <code>zip</code> family of tasks support an
  266. option <var>createUnicodeExtraFields</var>, which makes Ant write these extra fields either for all
  267. entries (<q>always</q>) or only those whose name cannot be encoded using the specified encoding
  268. (<q>not-encodeable</q>), it defaults to <q>never</q> since the extra fields create bigger
  269. archives.</p>
  270. <p>The <var>fallbackToUTF8</var> attribute of <code>zip</code> can be used to create archives that
  271. use the specified encoding in the majority of cases but UTF-8 and the language encoding flag for
  272. filenames that cannot be encoded using the specified encoding.</p>
  273. <p>The <code>unzip</code> task will recognize the Unicode extra fields by default and read the file
  274. name information from them, unless you set the optional
  275. attribute <var>scanForUnicodeExtraFields</var> to <q>false</q>.</p>
  276. <h4>Recommendations for interoperability</h4>
  277. <p>The optimal setting of flags depends on the archivers you expect as consumers/producers of the
  278. ZIP archives. Below are some test results which may be superseded with later versions of each
  279. tool.</p>
  280. <ul>
  281. <li>The <code class="code">java.util.zip</code> package used by the <kbd>jar</kbd> executable or
  282. to read jars from your <code>CLASSPATH</code> reads and writes UTF-8 names, it doesn't set or
  283. recognize any flags or unicode extra fields.</li>
  284. <li>Since Java 7, <code class="code">java.util.zip</code> writes UTF-8 by default and uses the
  285. language encoding flag. It is possible to specify a different encoding when reading/writing
  286. ZIPs via new constructors. The package now recognizes the language encoding flag when reading
  287. and ignores the Unicode extra fields.</li>
  288. <li>7Zip writes CodePage 437 by default but uses UTF-8 and the language encoding flag when writing
  289. entries that cannot be encoded as CodePage 437 (similar to the <code>zip</code> task
  290. with <var>fallbacktoUTF8</var> set to <q>true</q>). It recognizes the language encoding flag
  291. when reading and ignores the Unicode extra fields.</li>
  292. <li>WinZIP writes CodePage 437 and uses Unicode extra fields by default. It recognizes the
  293. Unicode extra field and the language encoding flag when reading.</li>
  294. <li>Windows' "compressed folder" feature doesn't recognize any flag or extra field and creates
  295. archives using the default platform encoding&mdash;and expects archives to be in that encoding
  296. when reading them.</li>
  297. <li>InfoZIP based tools can recognize and write both, it is a compile time option and depends on
  298. the platform so your mileage may vary.</li>
  299. <li>PKWARE zip tools recognize both and prefer the language encoding flag. They create archives
  300. using CodePage 437 if possible and UTF-8 plus the language encoding flag for file names that
  301. cannot be encoded as CodePage 437.</li>
  302. </ul>
  303. <p>So, what to do?</p>
  304. <p>If you are creating jars, then <code class="code">java.util.zip</code> is your main consumer. We
  305. recommend you set the encoding to UTF-8 and keep the language encoding flag enabled. The flag won't
  306. help or hurt <code class="code">java.util.zip</code> prior to Java 7 but archivers that support it
  307. will show the correct file names.</p>
  308. <p>For maximum interoparability it is probably best to set the encoding to UTF-8, enable the
  309. language encoding flag and create Unicode extra fields when writing ZIPs. Such archives should be
  310. extracted correctly by <code class="code">java.util.zip</code>, 7Zip, WinZIP, PKWARE tools and most
  311. likely InfoZIP tools. They will be unusable with Windows' "compressed folders" feature and bigger
  312. than archives without the Unicode extra fields, though.</p>
  313. <p>If Windows' "compressed folders" is your primary consumer, then your best option is to explicitly
  314. set the encoding to the target platform. You may want to enable creation of Unicode extra fields so
  315. the tools that support them will extract the file names correctly.</p>
  316. <h3 id="zip64">Zip64 extensions</h3>
  317. <p>Zip64 extensions provide a way to create archives bigger than 4 GB or holding more than 65535
  318. entries&mdash;or add individual entries bigger than 4 GB using the ZIP extension field mechanism.
  319. These extensions are supported by most modern ZIP implementations.</p>
  320. <p>When Ant writes compressed entries into the archive it creates it doesn't know the compressed
  321. size of an entry before it has been written. Unfortunately the decision whether a Zip64 extra field
  322. will be written has to be made before writing the entry's content.</p>
  323. <p>Ant 1.9.0 introduced support for Zip64 extensions but didn't provide any control over their
  324. usage. <em>Since Ant 1.9.1</em>, a new <var>zip64mode</var> attribute was added to
  325. the <code>zip</code> family of tasks. It supports three values:
  326. <ul>
  327. <li><q>never</q> means no Zip64 extra fields will ever be written. This is the behavior of Ant
  328. prior to 1.9.0 and the default behavior of <code>jar</code>, <code>ear</code>
  329. and <code>war</code> <em>since Ant 1.9.1</em>.</li>
  330. <li><q>always</q> means Zip64 extra fields are written for all entries.</li>
  331. <li><q>as-needed</q> means Zip64 extra fields are written for all compressed entries to the "local
  332. file header" (by default these are all files but not the directories) but only written to the
  333. central directory if the entry really required Zip64 features. This is the default behavior of
  334. Ant 1.9.0 and remains the default behavior of the <code>zip</code> task.</li>
  335. </ul>
  336. <p><q>as-needed</q> provides a good compromise if you don't know whether you archive will exceed the
  337. limits of traditional zip files but don't want to waste too much space (the Zip64 extensions take up
  338. extra space). Unfortunately some ZIP implementations don't understand Zip64 extra fields or fail to
  339. parse archives with extra fields in local file headers that are not present in the central
  340. directory, one such implementation is the <code class="code">java.util.zip</code> package of Java 5,
  341. that's why the <code>jar</code> tasks default to <q>never</q>. Archives created
  342. with <q>as-needed</q> can be read without problems with Java 6 and later.</p>
  343. <h3>Parameters specified as nested elements</h3>
  344. <h4>any resource collection</h4>
  345. <p><a href="../Types/resources.html#collection">resource collections</a> are used to select groups
  346. of files to archive.</p>
  347. <p>Prior to Ant 1.7 only <code>&lt;fileset&gt;</code> and <code>&lt;zipfileset&gt;</code> have been
  348. supported as nested elements.</p>
  349. <h4 id="zipgroupfileset">zipgroupfileset</h4>
  350. <p>A <code>&lt;zipgroupfileset&gt;</code> allows for multiple zip files to be merged into the
  351. archive. Each file found in this fileset is added to the archive the same way
  352. that <code>zipfileset</code> <var>src</var> files are added.</p>
  353. <p><code>&lt;zipgroupfileset&gt;</code> is a <a href="../Types/fileset.html">fileset</a> and
  354. supports all of its attributes and nested elements.</p>
  355. <h3>Examples</h3>
  356. <p>Zip all files in the <samp>htdocs/manual</samp> directory into a file
  357. called <samp>manual.zip</samp> in the <samp>${dist}</samp> directory.</p>
  358. <pre>
  359. &lt;zip destfile=&quot;${dist}/manual.zip&quot;
  360. basedir=&quot;htdocs/manual&quot;/&gt;</pre>
  361. <p>Zip all files in the <samp>htdocs/manual</samp> directory into a file
  362. called <samp>manual.zip</samp> in the <samp>${dist}</samp> directory. If <samp>manual.zip</samp>
  363. doesn't exist, it is created; otherwise it is updated with the new/changed files.</p>
  364. <pre>
  365. &lt;zip destfile=&quot;${dist}/manual.zip&quot;
  366. basedir=&quot;htdocs/manual&quot;
  367. update=&quot;true&quot;/&gt;</pre>
  368. <p>Zip all files in the <samp>htdocs/manual</samp> directory. Files in the
  369. directory <samp>mydocs</samp>, or files with the name <samp>todo.html</samp> are excluded.</p>
  370. <pre>
  371. &lt;zip destfile=&quot;${dist}/manual.zip&quot;
  372. basedir=&quot;htdocs/manual&quot;
  373. excludes=&quot;mydocs/**, **/todo.html&quot;/&gt;</pre>
  374. <p>Zip all files in the <samp>htdocs/manual</samp> directory. Only <samp>html</samp> files under the
  375. directory <samp>api</samp> are zipped, and files with the name <samp>todo.html</samp> are
  376. excluded.</p>
  377. <pre>
  378. &lt;zip destfile=&quot;${dist}/manual.zip&quot;
  379. basedir=&quot;htdocs/manual&quot;
  380. includes=&quot;api/**/*.html&quot;
  381. excludes=&quot;**/todo.html&quot;/&gt;</pre>
  382. <p>Zip all files in the <samp>htdocs/manual</samp> directory, and also add the
  383. file <samp>ChangeLog.txt</samp> in the current directory. <samp>ChangeLog.txt</samp> will be added
  384. to the top of the ZIP file, just as if it had been located
  385. at <samp>htdocs/manual/ChangeLog.txt</samp>.</p>
  386. <pre>
  387. &lt;zip destfile=&quot;${dist}/manual.zip&quot;&gt;
  388. &lt;fileset dir=&quot;htdocs/manual&quot;/&gt;
  389. &lt;fileset dir=&quot;.&quot; includes=&quot;ChangeLog.txt&quot;/&gt;
  390. &lt;/zip&gt;</pre>
  391. <p>Zip all files in the <samp>htdocs/manual</samp> directory into the <samp>docs/user-guide</samp>
  392. directory in the archive, adds the file <samp>ChangeLog27.txt</samp> in the current directory
  393. as <samp>docs/ChangeLog.txt</samp>, and includes all the <samp>html</samp> files
  394. in <samp>examples.zip</samp> under <samp>docs/examples</samp>.</p>
  395. <pre>
  396. &lt;zip destfile=&quot;${dist}/manual.zip&quot;&gt;
  397. &lt;zipfileset dir=&quot;htdocs/manual&quot; prefix=&quot;docs/user-guide&quot;/&gt;
  398. &lt;zipfileset dir=&quot;.&quot; includes=&quot;ChangeLog27.txt&quot; fullpath=&quot;docs/ChangeLog.txt&quot;/&gt;
  399. &lt;zipfileset src=&quot;examples.zip&quot; includes=&quot;**/*.html&quot; prefix=&quot;docs/examples&quot;/&gt;
  400. &lt;/zip&gt;</pre>
  401. <p>The archive might end up containing the files:</p>
  402. <pre>
  403. docs/user-guide/html/index.html
  404. docs/ChangeLog.txt
  405. docs/examples/index.html</pre>
  406. <p>Zip all files in the <samp>htdocs/manual</samp> directory into the <samp>docs/user-guide</samp>
  407. directory in the archive and include all the files in any file that
  408. matches <samp>examples*.zip</samp>, such as all files within <samp>examples1.zip</samp>
  409. or <samp>examples_for_brian.zip</samp>.</p>
  410. <pre>
  411. &lt;zip destfile=&quot;${dist}/manual.zip&quot;&gt;
  412. &lt;zipfileset dir=&quot;htdocs/manual&quot; prefix=&quot;docs/user-guide&quot;/&gt;
  413. &lt;zipgroupfileset dir=&quot;.&quot; includes=&quot;examples*.zip&quot;/&gt;
  414. &lt;/zip&gt;</pre>
  415. <p>The same can be achieved with</p>
  416. <pre>
  417. &lt;zip destfile=&quot;${dist}/manual.zip&quot;&gt;
  418. &lt;mappedresources&gt;
  419. &lt;fileset dir=&quot;htdocs/manual&quot;/&gt;
  420. &lt;globmapper from="*" to="docs/user-guide/*"/&gt;
  421. &lt;/mappedresources&gt;
  422. &lt;archives&gt;
  423. &lt;zips&gt;
  424. &lt;fileset dir=&quot;.&quot; includes=&quot;examples*.zip&quot;/&gt;
  425. &lt;/zips&gt;
  426. &lt;/archives&gt;
  427. &lt;/zip&gt;</pre>
  428. <p>Re-package a TAR archive as a ZIP archive. If Unix file permissions have been stored as part of
  429. the TAR file, they will be retained in the resulting ZIP archive.</p>
  430. <pre>
  431. &lt;zip destfile="release.zip"&gt;
  432. &lt;tarfileset src="release.tar"/&gt;
  433. &lt;/zip&gt;</pre>
  434. </body>
  435. </html>