source: release-kits/lirk3/bin/ant-installer/web/manual/manual/CoreTasks/unzip.html@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 6.2 KB
Line 
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
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16-->
17<html>
18
19<head>
20<meta http-equiv="Content-Language" content="en-us">
21<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
22<title>Unzip Task</title>
23</head>
24
25<body>
26
27<h2><a name="unzip">Unjar/Untar/Unwar/Unzip</a></h2>
28<h3>Description</h3>
29<p>Unzips a zip-, war-, or jar file.</p>
30<p><a href="../CoreTypes/patternset.html">PatternSet</a>s are used to select files to extract
31<I>from</I> the archive. If no patternset is used, all files are extracted.
32</p>
33
34<p><a href="../CoreTypes/resources.html#collection">Resource
35Collection</a>s may be used to select archived files to perform
36unarchival upon. Only file system based resource collections are
37supported by Unjar/Unwar/Unzip, this includes <a
38href="../CoreTypes/fileset.html">fileset</a>, <a
39href="../CoreTypes/filelist.html">filelist</a>, <a
40href="../using.html#path">path</a>, and <a
41href="../CoreTypes/resources.html#files">files</a>.
42Untar supports arbitrary resource collections.
43Prior to Ant 1.7 only fileset has been supported as a nested element.</p>
44
45<p>You can define filename transformations by using a nested <a href="../CoreTypes/mapper.html">mapper</a> element. The default mapper is the
46<a href="../CoreTypes/mapper.html#identity-mapper">identity mapper</a>.
47</p>
48<p>File permissions will not be restored on extracted files.</p>
49<p>The untar task recognizes the long pathname entries used by GNU tar.<p>
50<h3>Parameters</h3>
51<table border="1" cellpadding="2" cellspacing="0">
52 <tr>
53 <td valign="top"><b>Attribute</b></td>
54 <td valign="top"><b>Description</b></td>
55 <td align="center" valign="top"><b>Required</b></td>
56 </tr>
57 <tr>
58 <td valign="top">src</td>
59 <td valign="top">archive file to expand.</td>
60 <td align="center" valign="top">Yes, if filesets are not used.</td>
61 </tr>
62 <tr>
63 <td valign="top">dest</td>
64 <td valign="top">directory where to store the expanded files.</td>
65 <td align="center" valign="top">Yes</td>
66 </tr>
67 <tr>
68 <td valign="top">overwrite</td>
69 <td valign="top">Overwrite files, even if they are newer than the
70 corresponding entries in the archive (true or false, default is
71 true).</td>
72 <td align="center" valign="top">No</td>
73 </tr>
74 <tr>
75 <td valign="top">compression</td>
76 <td valign="top"><b>Note:</b> This attribute is only available for
77 the <code>untar</code> task.<br>
78 compression method. Allowable values are &quot;none&quot;,
79 &quot;gzip&quot; and &quot;bzip2&quot;. Default is
80 &quot;none&quot;.</td>
81 <td valign="top" align="center">No</td>
82 </tr>
83 <tr>
84 <td valign="top">encoding</td>
85 <td valign="top"><b>Note:</b> This attribute is not available for
86 the <code>untar</code> task.<br>
87 The character encoding that has been used for filenames
88 inside the zip file. For a list of possible values see <a
89 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>
90 Defaults to &quot;UTF8&quot;, use the magic value
91 <code>native-encoding</code> for the platform's default character
92 encoding.</td>
93 <td align="center" valign="top">No</td>
94 </tr>
95
96</table>
97<h3>Examples</h3>
98<pre>
99&lt;unzip src=&quot;${tomcat_src}/tools-src.zip&quot; dest=&quot;${tools.home}&quot;/&gt;
100</pre>
101<p>
102<pre>
103&lt;gunzip src=&quot;tools.tar.gz&quot;/&gt;
104&lt;untar src=&quot;tools.tar&quot; dest=&quot;${tools.home}&quot;/&gt;
105</pre>
106<pre>
107&lt;unzip src=&quot;${tomcat_src}/tools-src.zip&quot;
108 dest=&quot;${tools.home}&quot;&gt;
109 &lt;patternset&gt;
110 &lt;include name=&quot;**/*.java&quot;/&gt;
111 &lt;exclude name=&quot;**/Test*.java&quot;/&gt;
112 &lt;/patternset&gt;
113&lt;/unzip&gt;
114</pre>
115<p>
116<pre>
117&lt;unzip dest=&quot;${tools.home}&quot;&gt;
118 &lt;patternset&gt;
119 &lt;include name=&quot;**/*.java&quot;/&gt;
120 &lt;exclude name=&quot;**/Test*.java&quot;/&gt;
121 &lt;/patternset&gt;
122 &lt;fileset dir=&quot;.&quot;&gt;
123 &lt;include name=&quot;**/*.zip&quot;/&gt;
124 &lt;exclude name=&quot;**/tmp*.zip&quot;/&gt;
125 &lt;/fileset&gt;
126&lt;/unzip&gt;
127</pre>
128<p>
129<pre>
130&lt;unzip src=&quot;apache-ant-bin.zip&quot; dest=&quot;${tools.home}&quot;&gt;
131 &lt;patternset&gt;
132 &lt;include name=&quot;apache-ant/lib/ant.jar&quot;/&gt;
133 &lt;/patternset&gt;
134 &lt;mapper type=&quot;flatten&quot;/&gt;
135&lt;/unzip&gt;
136</pre>
137
138<h3>Related tasks</h3>
139
140<pre>
141&lt;unzip src="some-archive" dest="some-dir"&gt;
142 &lt;patternset&gt;
143 &lt;include name="some-pattern"/&gt;
144 &lt;/patternset&gt;
145 &lt;mapper type=&quot;some-mapper&quot;/&gt;
146&lt;/unzip&gt;
147</pre>
148
149is identical to
150
151<pre>
152&lt;copy todir="some-dir" preservelastmodified="true"&gt;
153 &lt;zipfileset src="some-archive"&gt;
154 &lt;patternset&gt;
155 &lt;include name="some-pattern"/&gt;
156 &lt;/patternset&gt;
157 &lt;/zipfileset&gt;
158 &lt;mapper type=&quot;some-mapper&quot;/&gt;
159&lt;/copy&gt;
160</pre>
161
162<p>The same is also true for <code>&lt;untar&gt;</code> and
163<code>&lt;tarfileset&gt;</code>. <code>&lt;copy&gt;</code> offers
164additional features like <a href="../CoreTypes/filterchain.html">filtering files</a> on the fly,
165allowing a file to be mapped to multiple destinations or a
166configurable file system timestamp granularity.</p>
167
168<pre>&lt;zip destfile=&quot;new.jar&quot;&gt;
169 &lt;zipfileset src=&quot;old.jar&quot;&gt;
170 &lt;exclude name=&quot;do/not/include/this/class&quot;/&gt;
171 &lt;/zipfileset&gt;
172&lt;/zip&gt;
173</pre>
174<p>&quot;Deletes&quot; files from a zipfile.</p>
175
176
177</body>
178</html>
Note: See TracBrowser for help on using the repository browser.