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.

unzip.html 5.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  5. <title>Unzip Task</title>
  6. </head>
  7. <body>
  8. <h2><a name="unzip">Unjar/Untar/Unwar/Unzip</a></h2>
  9. <h3>Description</h3>
  10. <p>Unzips a zip-, war-, or jar file.</p>
  11. <p><a href="../CoreTypes/patternset.html">PatternSet</a>s are used to select files to extract
  12. <I>from</I> the archive. If no patternset is used, all files are extracted.
  13. </p>
  14. <p><a href="../CoreTypes/resources.html#collection">Resource
  15. Collection</a>s may be used to select archived files to perform
  16. unarchival upon. Only file system based resource collections are
  17. supported by Unjar/Unwar/Unzip, this includes <a
  18. href="../CoreTypes/fileset.html">fileset</a>, <a
  19. href="../CoreTypes/filelist.html">filelist</a>, <a
  20. href="../using.html#path">path</a>, and <a
  21. href="../CoreTypes/resources.html#files">files</a>.
  22. Untar supports arbitrary resource collections.
  23. Prior to Ant 1.7 only fileset has been supported as a nested element.</p>
  24. <p>You can define filename transformations by using a nested <a href="../CoreTypes/mapper.html">mapper</a> element. The default mapper is the
  25. <a href="../CoreTypes/mapper.html#identity-mapper">identity mapper</a>.
  26. </p>
  27. <p>File permissions will not be restored on extracted files.</p>
  28. <p>The untar task recognizes the long pathname entries used by GNU tar.<p>
  29. <h3>Parameters</h3>
  30. <table border="1" cellpadding="2" cellspacing="0">
  31. <tr>
  32. <td valign="top"><b>Attribute</b></td>
  33. <td valign="top"><b>Description</b></td>
  34. <td align="center" valign="top"><b>Required</b></td>
  35. </tr>
  36. <tr>
  37. <td valign="top">src</td>
  38. <td valign="top">archive file to expand.</td>
  39. <td align="center" valign="top">Yes, if filesets are not used.</td>
  40. </tr>
  41. <tr>
  42. <td valign="top">dest</td>
  43. <td valign="top">directory where to store the expanded files.</td>
  44. <td align="center" valign="top">Yes</td>
  45. </tr>
  46. <tr>
  47. <td valign="top">overwrite</td>
  48. <td valign="top">Overwrite files, even if they are newer than the
  49. corresponding entries in the archive (true or false, default is
  50. true).</td>
  51. <td align="center" valign="top">No</td>
  52. </tr>
  53. <tr>
  54. <td valign="top">compression</td>
  55. <td valign="top"><b>Note:</b> This attribute is only available for
  56. the <code>untar</code> task.<br>
  57. compression method. Allowable values are &quot;none&quot;,
  58. &quot;gzip&quot; and &quot;bzip2&quot;. Default is
  59. &quot;none&quot;.</td>
  60. <td valign="top" align="center">No</td>
  61. </tr>
  62. <tr>
  63. <td valign="top">encoding</td>
  64. <td valign="top"><b>Note:</b> This attribute is not available for
  65. the <code>untar</code> task.<br>
  66. The character encoding that has been used for filenames
  67. inside the zip file. For a list of possible values see <a
  68. href="http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html">http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html</a>.<br>
  69. Defaults to &quot;UTF8&quot;, use the magic value
  70. <code>native-encoding</code> for the platform's default character
  71. encoding.</td>
  72. <td align="center" valign="top">No</td>
  73. </tr>
  74. </table>
  75. <h3>Examples</h3>
  76. <pre>
  77. &lt;unzip src=&quot;${tomcat_src}/tools-src.zip&quot; dest=&quot;${tools.home}&quot;/&gt;
  78. </pre>
  79. <p>
  80. <pre>
  81. &lt;gunzip src=&quot;tools.tar.gz&quot;/&gt;
  82. &lt;untar src=&quot;tools.tar&quot; dest=&quot;${tools.home}&quot;/&gt;
  83. </pre>
  84. <pre>
  85. &lt;unzip src=&quot;${tomcat_src}/tools-src.zip&quot;
  86. dest=&quot;${tools.home}&quot;&gt;
  87. &lt;patternset&gt;
  88. &lt;include name=&quot;**/*.java&quot;/&gt;
  89. &lt;exclude name=&quot;**/Test*.java&quot;/&gt;
  90. &lt;/patternset&gt;
  91. &lt;/unzip&gt;
  92. </pre>
  93. <p>
  94. <pre>
  95. &lt;unzip dest=&quot;${tools.home}&quot;&gt;
  96. &lt;patternset&gt;
  97. &lt;include name=&quot;**/*.java&quot;/&gt;
  98. &lt;exclude name=&quot;**/Test*.java&quot;/&gt;
  99. &lt;/patternset&gt;
  100. &lt;fileset dir=&quot;.&quot;&gt;
  101. &lt;include name=&quot;**/*.zip&quot;/&gt;
  102. &lt;exclude name=&quot;**/tmp*.zip&quot;/&gt;
  103. &lt;/fileset&gt;
  104. &lt;/unzip&gt;
  105. </pre>
  106. <p>
  107. <pre>
  108. &lt;unzip src=&quot;apache-ant-bin.zip&quot; dest=&quot;${tools.home}&quot;&gt;
  109. &lt;patternset&gt;
  110. &lt;include name=&quot;apache-ant/lib/ant.jar&quot;/&gt;
  111. &lt;/patternset&gt;
  112. &lt;mapper type=&quot;flatten&quot;/&gt;
  113. &lt;/unzip&gt;
  114. </pre>
  115. <h3>Related tasks</h3>
  116. <pre>
  117. &lt;unzip src="some-archive" dest="some-dir"&gt;
  118. &lt;patternset&gt;
  119. &lt;include name="some-pattern"/&gt;
  120. &lt;/patternset&gt;
  121. &lt;mapper type=&quot;some-mapper&quot;/&gt;
  122. &lt;/unzip&gt;
  123. </pre>
  124. is identical to
  125. <pre>
  126. &lt;copy todir="some-dir" preservelastmodified="true"&gt;
  127. &lt;zipfileset src="some-archive"&gt;
  128. &lt;patternset&gt;
  129. &lt;include name="some-pattern"/&gt;
  130. &lt;/patternset&gt;
  131. &lt;/zipfileset&gt;
  132. &lt;mapper type=&quot;some-mapper&quot;/&gt;
  133. &lt;/copy&gt;
  134. </pre>
  135. <p>The same is also true for <code>&lt;untar&gt;</code> and
  136. <code>&lt;tarfileset&gt;</code>. <code>&lt;copy&gt;</code> offers
  137. additional features like <a
  138. href="../CoreTypes/filterchain.html">filtering files</a> on the fly,
  139. allowing a file to be mapped to multiple destinations or a
  140. configurable file system timestamp granularity.</p>
  141. <hr>
  142. <p align="center">Copyright &copy; 2000-2006 The Apache Software Foundation. All rights
  143. Reserved.</p>
  144. </body>
  145. </html>