PageRenderTime 55ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/projects/ant-1.8.2/docs/manual/Tasks/unzip.html

https://gitlab.com/essere.lab.public/qualitas.class-corpus
HTML | 243 lines | 209 code | 18 blank | 16 comment | 0 complexity | 9da4e0df70216b1faad773220cf79a6e MD5 | raw file
  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>Unzip Task</title>
  20. </head>
  21. <body>
  22. <h2><a name="unzip">Unjar/Untar/Unwar/Unzip</a></h2>
  23. <h3>Description</h3>
  24. <p>Unzips a zip-, war-, or jar file.</p>
  25. <p><a href="../Types/patternset.html">PatternSet</a>s are used to select files to extract
  26. <I>from</I> the archive. If no patternset is used, all files are extracted.
  27. </p>
  28. <p><a href="../Types/resources.html#collection">Resource
  29. Collection</a>s may be used to select archived files to perform
  30. unarchival upon. Only file system based resource collections are
  31. supported by Unjar/Unwar/Unzip, this includes <a
  32. href="../Types/fileset.html">fileset</a>, <a
  33. href="../Types/filelist.html">filelist</a>, <a
  34. href="../using.html#path">path</a>, and <a
  35. href="../Types/resources.html#files">files</a>.
  36. Untar supports arbitrary resource collections.
  37. Prior to Apache Ant 1.7 only fileset has been supported as a nested element.</p>
  38. <p>You can define filename transformations by using a nested <a href="../Types/mapper.html">mapper</a> element. The default mapper is the
  39. <a href="../Types/mapper.html#identity-mapper">identity mapper</a>.
  40. </p>
  41. <p>File permissions will not be restored on extracted files.</p>
  42. <p>The untar task recognizes the long pathname entries used by GNU tar.<p>
  43. <p><b>Please note</b> that different ZIP tools handle timestamps
  44. differently when it comes to applying timezone offset calculations of
  45. files. Some ZIP libraries will store the timestamps as they've been
  46. read from the filesystem while others will modify the timestamps both
  47. when reading and writing the files to make all timestamps use the same
  48. timezone. A ZIP archive created by one library may extract files with
  49. "wrong timestamps" when extracted by another library.</p>
  50. <p>Ant's ZIP classes use the same algorithm as the InfoZIP tools and
  51. zlib (timestamps get adjusted), Windows' "compressed folders" function
  52. and WinZIP don't change the timestamps. This means that using the
  53. unzip task on files created by Windows' compressed folders function
  54. may create files with timestamps that are "wrong", the same is true if
  55. you use Windows' functions to extract an Ant generated ZIP
  56. archive.</p>
  57. <h3>Parameters</h3>
  58. <table border="1" cellpadding="2" cellspacing="0">
  59. <tr>
  60. <td valign="top"><b>Attribute</b></td>
  61. <td valign="top"><b>Description</b></td>
  62. <td align="center" valign="top"><b>Required</b></td>
  63. </tr>
  64. <tr>
  65. <td valign="top">src</td>
  66. <td valign="top">archive file to expand.</td>
  67. <td align="center" valign="top">Yes, if filesets are not used.</td>
  68. </tr>
  69. <tr>
  70. <td valign="top">dest</td>
  71. <td valign="top">directory where to store the expanded files.</td>
  72. <td align="center" valign="top">Yes</td>
  73. </tr>
  74. <tr>
  75. <td valign="top">overwrite</td>
  76. <td valign="top">Overwrite files, even if they are newer than the
  77. corresponding entries in the archive (true or false, default is
  78. true).</td>
  79. <td align="center" valign="top">No</td>
  80. </tr>
  81. <tr>
  82. <td valign="top">compression</td>
  83. <td valign="top"><b>Note:</b> This attribute is only available for
  84. the <code>untar</code> task.<br>
  85. compression method. Allowable values are &quot;none&quot;,
  86. &quot;gzip&quot; and &quot;bzip2&quot;. Default is
  87. &quot;none&quot;.</td>
  88. <td valign="top" align="center">No</td>
  89. </tr>
  90. <tr>
  91. <td valign="top">encoding</td>
  92. <td valign="top"><b>Note:</b> This attribute is not available for
  93. the <code>untar</code> task.<br>
  94. The character encoding that has been used for filenames
  95. inside the zip file. For a list of possible values see <a
  96. href="http://download.oracle.com/javase/1.5.0/docs/guide/intl/encoding.doc.html">http://download.oracle.com/javase/1.5.0/docs/guide/intl/encoding.doc.html</a>.<br>
  97. Defaults to &quot;UTF8&quot;, use the magic value
  98. <code>native-encoding</code> for the platform's default character
  99. encoding.
  100. <br/>See also the <a href="zip.html#encoding">discussion in the
  101. zip task page</a></td>
  102. <td align="center" valign="top">No</td>
  103. </tr>
  104. <tr>
  105. <td valign="top">failOnEmptyArchive</td>
  106. <td valign="top">whether trying to extract an empty archive is an
  107. error. <em>since Ant 1.8.0</em></td>
  108. <td valign="top" align="center">No, defaults to false</td>
  109. </tr>
  110. <tr>
  111. <td valign="top">stripAbsolutePathSpec</td>
  112. <td valign="top">whether Ant should remove leading '/' or '\'
  113. characters from the extracted file name before extracing it.
  114. Note that this changes the entry's name before applying
  115. include/exclude patterns and before using the nested mappers (if
  116. any). <em>since Ant 1.8.0</em></td>
  117. <td valign="top" align="center">No, defaults to false</td>
  118. </tr>
  119. <tr>
  120. <td valign="top">scanForUnicodeExtraFields</td>
  121. <td valign="top"><b>Note:</b> This attribute is not available for
  122. the <code>untar</code> task.<br>
  123. If the archive contains uncode extra fields then use them to set
  124. the file names, ignoring the specified encoding.
  125. <br/>See also the <a href="zip.html#encoding">discussion in the
  126. zip task page</a></td>
  127. <td align="center" valign="top">No, defaults to true</td>
  128. </tr>
  129. </table>
  130. <h3>Examples</h3>
  131. <pre>
  132. &lt;unzip src=&quot;${tomcat_src}/tools-src.zip&quot; dest=&quot;${tools.home}&quot;/&gt;
  133. </pre>
  134. <p>
  135. <pre>
  136. &lt;gunzip src=&quot;tools.tar.gz&quot;/&gt;
  137. &lt;untar src=&quot;tools.tar&quot; dest=&quot;${tools.home}&quot;/&gt;
  138. </pre>
  139. <pre>
  140. &lt;unzip src=&quot;${tomcat_src}/tools-src.zip&quot;
  141. dest=&quot;${tools.home}&quot;&gt;
  142. &lt;patternset&gt;
  143. &lt;include name=&quot;**/*.java&quot;/&gt;
  144. &lt;exclude name=&quot;**/Test*.java&quot;/&gt;
  145. &lt;/patternset&gt;
  146. &lt;/unzip&gt;
  147. </pre>
  148. <p>
  149. <pre>
  150. &lt;unzip dest=&quot;${tools.home}&quot;&gt;
  151. &lt;patternset&gt;
  152. &lt;include name=&quot;**/*.java&quot;/&gt;
  153. &lt;exclude name=&quot;**/Test*.java&quot;/&gt;
  154. &lt;/patternset&gt;
  155. &lt;fileset dir=&quot;.&quot;&gt;
  156. &lt;include name=&quot;**/*.zip&quot;/&gt;
  157. &lt;exclude name=&quot;**/tmp*.zip&quot;/&gt;
  158. &lt;/fileset&gt;
  159. &lt;/unzip&gt;
  160. </pre>
  161. <p>
  162. <pre>
  163. &lt;unzip src=&quot;apache-ant-bin.zip&quot; dest=&quot;${tools.home}&quot;&gt;
  164. &lt;patternset&gt;
  165. &lt;include name=&quot;apache-ant/lib/ant.jar&quot;/&gt;
  166. &lt;/patternset&gt;
  167. &lt;mapper type=&quot;flatten&quot;/&gt;
  168. &lt;/unzip&gt;
  169. </pre>
  170. <h3>Related tasks</h3>
  171. <pre>
  172. &lt;unzip src="some-archive" dest="some-dir"&gt;
  173. &lt;patternset&gt;
  174. &lt;include name="some-pattern"/&gt;
  175. &lt;/patternset&gt;
  176. &lt;mapper type=&quot;some-mapper&quot;/&gt;
  177. &lt;/unzip&gt;
  178. </pre>
  179. is identical to
  180. <pre>
  181. &lt;copy todir="some-dir" preservelastmodified="true"&gt;
  182. &lt;zipfileset src="some-archive"&gt;
  183. &lt;patternset&gt;
  184. &lt;include name="some-pattern"/&gt;
  185. &lt;/patternset&gt;
  186. &lt;/zipfileset&gt;
  187. &lt;mapper type=&quot;some-mapper&quot;/&gt;
  188. &lt;/copy&gt;
  189. </pre>
  190. <p>The same is also true for <code>&lt;untar&gt;</code> and
  191. <code>&lt;tarfileset&gt;</code>. <code>&lt;copy&gt;</code> offers
  192. additional features like <a href="../Types/filterchain.html">filtering files</a> on the fly,
  193. allowing a file to be mapped to multiple destinations or a
  194. configurable file system timestamp granularity.</p>
  195. <pre>&lt;zip destfile=&quot;new.jar&quot;&gt;
  196. &lt;zipfileset src=&quot;old.jar&quot;&gt;
  197. &lt;exclude name=&quot;do/not/include/this/class&quot;/&gt;
  198. &lt;/zipfileset&gt;
  199. &lt;/zip&gt;
  200. </pre>
  201. <p>&quot;Deletes&quot; files from a zipfile.</p>
  202. <pre>
  203. &lt;unzip src=&quot;${ant.home}/lib/ant.jar&quot; dest=&quot;...&quot;&gt;
  204. &lt;patternset&gt;
  205. &lt;include name=&quot;images/&quot;/&gt;
  206. &lt;/patternset&gt;
  207. &lt;/unzip&gt;
  208. </pre>
  209. <p>This extracts all images from <tt>ant.jar</tt> which are stored in the <tt>images</tt> directory
  210. of the Jar (or somewhere under it). While extracting the directory structure (<tt>images</tt>)
  211. will be taken.</p>
  212. <pre>
  213. &lt;unzip src=&quot;${ant.home}/lib/ant.jar&quot; dest=&quot;...&quot;&gt;
  214. &lt;patternset&gt;
  215. &lt;include name=&quot;**/ant_logo_large.gif&quot;/&gt;
  216. &lt;include name=&quot;**/LICENSE.txt&quot;/&gt;
  217. &lt;/patternset&gt;
  218. &lt;/unzip&gt;
  219. </pre>
  220. <p>This extracts the two files <tt>ant_logo_large.gif</tt> and <tt>LICENSE.txt</tt> from the
  221. <tt>ant.jar</tt>. More exactly: it extracts all files with these names from anywhere in the source file. While extracting the directory structure will be taken.</p>
  222. </body>
  223. </html>