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
|
---|
35 | Collection</a>s may be used to select archived files to perform
|
---|
36 | unarchival upon. Only file system based resource collections are
|
---|
37 | supported by Unjar/Unwar/Unzip, this includes <a
|
---|
38 | href="../CoreTypes/fileset.html">fileset</a>, <a
|
---|
39 | href="../CoreTypes/filelist.html">filelist</a>, <a
|
---|
40 | href="../using.html#path">path</a>, and <a
|
---|
41 | href="../CoreTypes/resources.html#files">files</a>.
|
---|
42 | Untar supports arbitrary resource collections.
|
---|
43 | Prior 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 "none",
|
---|
79 | "gzip" and "bzip2". Default is
|
---|
80 | "none".</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 "UTF8", 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 | <unzip src="${tomcat_src}/tools-src.zip" dest="${tools.home}"/>
|
---|
100 | </pre>
|
---|
101 | <p>
|
---|
102 | <pre>
|
---|
103 | <gunzip src="tools.tar.gz"/>
|
---|
104 | <untar src="tools.tar" dest="${tools.home}"/>
|
---|
105 | </pre>
|
---|
106 | <pre>
|
---|
107 | <unzip src="${tomcat_src}/tools-src.zip"
|
---|
108 | dest="${tools.home}">
|
---|
109 | <patternset>
|
---|
110 | <include name="**/*.java"/>
|
---|
111 | <exclude name="**/Test*.java"/>
|
---|
112 | </patternset>
|
---|
113 | </unzip>
|
---|
114 | </pre>
|
---|
115 | <p>
|
---|
116 | <pre>
|
---|
117 | <unzip dest="${tools.home}">
|
---|
118 | <patternset>
|
---|
119 | <include name="**/*.java"/>
|
---|
120 | <exclude name="**/Test*.java"/>
|
---|
121 | </patternset>
|
---|
122 | <fileset dir=".">
|
---|
123 | <include name="**/*.zip"/>
|
---|
124 | <exclude name="**/tmp*.zip"/>
|
---|
125 | </fileset>
|
---|
126 | </unzip>
|
---|
127 | </pre>
|
---|
128 | <p>
|
---|
129 | <pre>
|
---|
130 | <unzip src="apache-ant-bin.zip" dest="${tools.home}">
|
---|
131 | <patternset>
|
---|
132 | <include name="apache-ant/lib/ant.jar"/>
|
---|
133 | </patternset>
|
---|
134 | <mapper type="flatten"/>
|
---|
135 | </unzip>
|
---|
136 | </pre>
|
---|
137 |
|
---|
138 | <h3>Related tasks</h3>
|
---|
139 |
|
---|
140 | <pre>
|
---|
141 | <unzip src="some-archive" dest="some-dir">
|
---|
142 | <patternset>
|
---|
143 | <include name="some-pattern"/>
|
---|
144 | </patternset>
|
---|
145 | <mapper type="some-mapper"/>
|
---|
146 | </unzip>
|
---|
147 | </pre>
|
---|
148 |
|
---|
149 | is identical to
|
---|
150 |
|
---|
151 | <pre>
|
---|
152 | <copy todir="some-dir" preservelastmodified="true">
|
---|
153 | <zipfileset src="some-archive">
|
---|
154 | <patternset>
|
---|
155 | <include name="some-pattern"/>
|
---|
156 | </patternset>
|
---|
157 | </zipfileset>
|
---|
158 | <mapper type="some-mapper"/>
|
---|
159 | </copy>
|
---|
160 | </pre>
|
---|
161 |
|
---|
162 | <p>The same is also true for <code><untar></code> and
|
---|
163 | <code><tarfileset></code>. <code><copy></code> offers
|
---|
164 | additional features like <a href="../CoreTypes/filterchain.html">filtering files</a> on the fly,
|
---|
165 | allowing a file to be mapped to multiple destinations or a
|
---|
166 | configurable file system timestamp granularity.</p>
|
---|
167 |
|
---|
168 | <pre><zip destfile="new.jar">
|
---|
169 | <zipfileset src="old.jar">
|
---|
170 | <exclude name="do/not/include/this/class"/>
|
---|
171 | </zipfileset>
|
---|
172 | </zip>
|
---|
173 | </pre>
|
---|
174 | <p>"Deletes" files from a zipfile.</p>
|
---|
175 |
|
---|
176 |
|
---|
177 | </body>
|
---|
178 | </html>
|
---|