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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Ant User Manual</title>
  5. </head>
  6. <body>
  7. <h2><a name="zip">Zip</a></h2>
  8. <h3>Description</h3>
  9. <p>Creates a zipfile.</p>
  10. <p>The <i>basedir</i> attribute is the reference directory from where to zip.</p>
  11. <p>Note that file permissions will not be stored in the resulting zipfile.</p>
  12. <p>It is possible to refine the set of files that are being zipped. This can be
  13. done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>, <i>excludesfile</i> and <i>defaultexcludes</i>
  14. attributes. With the <i>includes</i> or <i>includesfile</i> attribute you specify the files you want to
  15. have included by using patterns. The <i>exclude</i> or <i>excludesfile</i> attribute is used to specify
  16. the files you want to have excluded. This is also done with patterns. And
  17. finally with the <i>defaultexcludes</i> attribute, you can specify whether you
  18. want to use default exclusions or not. See the section on <a
  19. href="../dirtasks.html#directorybasedtasks">directory based tasks</a>, on how the
  20. inclusion/exclusion of files works, and how to write patterns. </p>
  21. <p>This task forms an implicit <a href="../CoreTypes/fileset.html">FileSet</a> and
  22. supports all attributes of <code>&lt;fileset&gt;</code>
  23. (<code>dir</code> becomes <code>basedir</code>) as well as the nested
  24. <code>&lt;include&gt;</code>, <code>&lt;exclude&gt;</code> and
  25. <code>&lt;patternset&gt;</code> elements.</p>
  26. <p>Or, you may place within it nested file sets, or references to file sets.
  27. In this case <code>basedir</code> is optional; the implicit file set is <i>only used</i>
  28. if <code>basedir</code> is set. You may use any mixture of the implicit file set
  29. (with <code>basedir</code> set, and optional attributes like <code>includes</code>
  30. and optional subelements like <code>&lt;include&gt;</code>); explicit nested
  31. <code>&lt;fileset&gt;</code> elements so long as at least one fileset total is specified. The ZIP file will
  32. 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>
  33. <p>The <code>whenempty</code> parameter controls what happens when no files match.
  34. If <code>skip</code> (the default), the ZIP is not created and a warning is issued.
  35. If <code>fail</code>, the ZIP is not created and the build is halted with an error.
  36. If <code>create</code>, an empty ZIP file (explicitly zero entries) is created,
  37. which should be recognized as such by compliant ZIP manipulation tools.</p>
  38. <h3>Parameters</h3>
  39. <table border="1" cellpadding="2" cellspacing="0">
  40. <tr>
  41. <td valign="top"><b>Attribute</b></td>
  42. <td valign="top"><b>Description</b></td>
  43. <td valign="top" align="center"><b>Required</b></td>
  44. </tr>
  45. <tr>
  46. <td valign="top">zipfile</td>
  47. <td valign="top">the zip-file to create.</td>
  48. <td align="center" valign="top">Yes</td>
  49. </tr>
  50. <tr>
  51. <td valign="top">basedir</td>
  52. <td valign="top">the directory from which to zip the files.</td>
  53. <td align="center" valign="top">No</td>
  54. </tr>
  55. <tr>
  56. <td valign="top">compress</td>
  57. <td valign="top">Not only store data but also compress them, defaults to true</td>
  58. <td align="center" valign="top">No</td>
  59. </tr>
  60. <tr>
  61. <td valign="top">includes</td>
  62. <td valign="top">comma separated list of patterns of files that must be
  63. included. All files are included when omitted.</td>
  64. <td valign="top" align="center">No</td>
  65. </tr>
  66. <tr>
  67. <td valign="top">includesfile</td>
  68. <td valign="top">the name of a file. Each line of this file is
  69. taken to be an include pattern</td>
  70. <td valign="top" align="center">No</td>
  71. </tr>
  72. <tr>
  73. <td valign="top">excludes</td>
  74. <td valign="top">comma separated list of patterns of files that must be
  75. excluded. No files (except default excludes) are excluded when omitted.</td>
  76. <td valign="top" align="center">No</td>
  77. </tr>
  78. <tr>
  79. <td valign="top">excludesfile</td>
  80. <td valign="top">the name of a file. Each line of this file is
  81. taken to be an exclude pattern</td>
  82. <td valign="top" align="center">No</td>
  83. </tr>
  84. <tr>
  85. <td valign="top">defaultexcludes</td>
  86. <td valign="top">indicates whether default excludes should be used or not
  87. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
  88. <td valign="top" align="center">No</td>
  89. </tr>
  90. <tr>
  91. <td valign="top">whenempty</td>
  92. <td valign="top">Behavior when no files match.</td>
  93. <td valign="top" align="center">No</td>
  94. </tr>
  95. </table>
  96. <h3>Parameters specified as nested elements</h3>
  97. <h4>fileset</h4>
  98. <p>The zip task supports any number of nested <a
  99. href="../CoreTypes/fileset.html"><code>&lt;fileset&gt;</code></a> elements to specify
  100. the files to be included in the archive.</p>
  101. <h4>zipfileset</h4>
  102. <p>A <code>&lt;zipfileset&gt;</code> has three additional attributes: <i>prefix</i>, <i>fullpath</i>, and <i>src</i>. The
  103. <i>prefix</i> and <i>fullpath</i> attributes modify the location of the files when they are placed
  104. inside the archive. If the <i>prefix</i> attribute is set, all files in the fileset are prefixed
  105. with that path in the archive. If the <i>fullpath</i> attribute is set, the file described by the fileset is placed at that
  106. exact location in the archive. (The <i>fullpath</i> attribute can only be set for filesets that represent a single file. The <i>prefix</i> and <i>fullpath</i> attributes cannot both be set on the same fileset.) The <i>src</i> attribute
  107. may be used in place of the <i>dir</i> attribute to specify a zip file whose
  108. contents will be extracted and included in the archive. As with directories, include and exclude patterns may be used to specify a subset of the zip file
  109. for inclusion in the archive.</p>
  110. <h3>Examples</h3>
  111. <pre> &lt;zip zipfile=&quot;${dist}/manual.zip&quot;
  112. basedir=&quot;htdocs/manual&quot;
  113. /&gt;</pre>
  114. <p>zips all files in the <code>htdocs/manual</code> directory into a file called <code>manual.zip</code>
  115. in the <code>${dist}</code> directory.</p>
  116. <pre> &lt;zip zipfile=&quot;${dist}/manual.zip&quot;
  117. basedir=&quot;htdocs/manual&quot;
  118. excludes=&quot;mydocs/**, **/todo.html&quot;
  119. /&gt;</pre>
  120. <p>zips all files in the <code>htdocs/manual</code> directory. Files in the directory <code>mydocs</code>,
  121. or files with the name <code>todo.html</code> are excluded.</p>
  122. <pre> &lt;zip zipfile=&quot;${dist}/manual.zip&quot;
  123. basedir=&quot;htdocs/manual&quot;
  124. includes=&quot;api/**/*.html&quot;
  125. excludes=&quot;**/todo.html&quot;
  126. /&gt;</pre>
  127. <p>zips all files in the <code>htdocs/manual</code> directory. Only html files under the directory <code>api</code>
  128. are zipped, and files with the name <code>todo.html</code> are excluded.</p>
  129. <pre> &lt;zip zipfile=&quot;${dist}/manual.zip&quot;&gt;
  130. &lt;fileset dir=&quot;htdocs/manual&quot;/&gt;
  131. &lt;fileset dir=&quot;.&quot; includes=&quot;ChangeLog.txt&quot;/&gt;
  132. &lt;/zip&gt;</pre>
  133. <p>zips all files in the <code>htdocs/manual</code> directory, and also adds the file <code>ChangeLog.txt</code> in the
  134. current directory. <code>ChangeLog.txt</code> will be added to the top of the ZIP file, just as if
  135. it had been located at <code>htdocs/manual/ChangeLog.txt</code>.</p>
  136. <pre> &lt;zip zipfile=&quot;${dist}/manual.zip&quot;&gt;
  137. &lt;zipfileset dir=&quot;htdocs/manual&quot; prefix=&quot;docs/user-guide&quot;/&gt;
  138. &lt;zipfileset dir=&quot;.&quot; includes=&quot;ChangeLog27.txt&quot; fullpath=&quot;docs/ChangeLog.txt&quot;/&gt;
  139. &lt;zipfileset src=&quot;examples.zip&quot; includes=&quot;**/*.html&quot; prefix=&quot;docs/examples&quot;/&gt;
  140. &lt;/zip&gt;</pre>
  141. <p>zips all files in the <code>htdocs/manual</code> directory into the <code>docs/user-guide</code> directory
  142. in the archive, adds the file <code>ChangeLog27.txt</code> in the
  143. current directory as <code>docs/ChangeLog.txt</code>, and includes all the html files in <code>examples.zip</code>
  144. under <code>docs/examples</code>. The archive might end up containing the files:</p>
  145. <pre><code> docs/user-guide/html/index.html
  146. docs/ChangeLog.txt
  147. docs/examples/index.html
  148. </code></pre>
  149. <hr>
  150. <p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
  151. Reserved.</p>
  152. </body>
  153. </html>