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 26 KiB

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