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

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

initial import of LiRK3

File size: 11.0 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>WAR Task</title>
23</head>
24
25<body>
26
27<h2><a name="war">War</a></h2>
28<h3>Description</h3>
29<p>An extension of the <a href="jar.html">Jar</a> task with special
30treatment for files that should end up in the
31<code>WEB-INF/lib</code>, <code>WEB-INF/classes</code> or
32<code>WEB-INF</code> directories of the Web Application Archive.</p>
33<p>(The War task is a shortcut for specifying the particular layout of a WAR file.
34The same thing can be accomplished by using the <i>prefix</i> and <i>fullpath</i>
35attributes of zipfilesets in a Zip or Jar task.)</p>
36<p>The extended zipfileset element from the zip task
37 (with attributes <i>prefix</i>, <i>fullpath</i>, and <i>src</i>)
38 is available in the War task. The task is also resource-enabled
39 and will add nested resources and resource collections to the archive.</p>
40
41<p>
42 Before Servlet API 2.5/Java EE 5, a WEB-INF/web.xml file was mandatory in a
43 WAR file, so this task failed if the <code>webxml</code> attribute was missing.
44 As the web.xml file is now optional, the <code>webxml</code> attribute may now
45 be made optional. However, as most real web applications do need a web.xml file,
46 it is not optional by default. The task will fail if the file is not
47 included, unless the <code>needxmlfile</code> attribute
48 is set to <code>true</code>. The task
49 will warn if more than one web.xml file is added to the JAR
50 through the filesets.
51</p>
52
53
54<p><b>Please note that the Zip format allows multiple files of the same
55fully-qualified name to exist within a single archive. This has been
56documented as causing various problems for unsuspecting users. If you wish
57to avoid this behavior you must set the <code>duplicate</code> attribute
58to a value other than its default, <code>&quot;add&quot;</code>.</b></p>
59
60<h3>Parameters</h3>
61<table border="1" cellpadding="2" cellspacing="0">
62 <tr>
63 <td valign="top"><b>Attribute</b></td>
64 <td valign="top"><b>Description</b></td>
65 <td align="center" valign="top"><b>Required</b></td>
66 </tr>
67 <tr>
68 <td valign="top">destfile</td>
69 <td valign="top">the WAR file to create.</td>
70 <td align="center" valign="top" rowspan="2">Exactly one of the two.</td>
71 </tr>
72 <tr>
73 <td valign="top">warfile</td>
74 <td valign="top"><i>Deprecated</i> name of the file to create
75 -use <tt>destfile</tt> instead.</td>
76 </tr>
77 <tr>
78 <td valign="top">webxml</td>
79 <td valign="top">The servlet configuration descriptor to use (WEB-INF/web.xml).</td>
80 <td valign="top" align="center">Yes, unless <tt>needxmlfile</tt> is true,
81 the file is pulled in via a nested fileset, or an existing WAR file is
82 being updated.</td>
83 </tr>
84 <tr>
85 <td valign="top">needxmlfile</td>
86 <td valign="top">Flag to indicate whether or not the web.xml file is needed.
87 I=it should be set to false when generating
88 servlet 2.5+ WAR files without a web.xml file.
89 <em>Since Ant 1.7</em></td>
90 <td valign="top" align="center">No -default "true"</td>
91 </tr>
92 <tr>
93 <td valign="top">basedir</td>
94 <td valign="top">the directory from which to jar the files.</td>
95 <td valign="top" align="center">No</td>
96 </tr>
97 <tr>
98 <td valign="top">compress</td>
99 <td valign="top">Not only store data but also compress them,
100 defaults to true. Unless you set the <em>keepcompression</em>
101 attribute to false, this will apply to the entire archive, not
102 only the files you've added while updating.</td>
103 <td align="center" valign="top">No</td>
104 </tr>
105 <tr>
106 <td valign="top">keepcompression</td>
107 <td valign="top">For entries coming from existing archives (like
108 nested <em>zipfileset</em>s or while updating the archive), keep
109 the compression as it has been originally instead of using the
110 <em>compress</em> attribute. Defaults false. <em>Since Ant
111 1.6</em></td>
112 <td align="center" valign="top">No</td>
113 </tr>
114 <tr>
115 <td valign="top">encoding</td>
116 <td valign="top">The character encoding to use for filenames
117 inside the archive. Defaults to UTF8. <strong>It is not
118 recommended to change this value as the created archive will most
119 likely be unreadable for Java otherwise.</strong></td>
120 <td align="center" valign="top">No</td>
121 </tr>
122 <tr>
123 <td valign="top">filesonly</td>
124 <td valign="top">Store only file entries, defaults to false</td>
125 <td align="center" valign="top">No</td>
126 </tr>
127 <tr>
128 <td valign="top">includes</td>
129 <td valign="top">comma- or space-separated list of patterns of files that must be
130 included. All files are included when omitted.</td>
131 <td valign="top" align="center">No</td>
132 </tr>
133 <tr>
134 <td valign="top">includesfile</td>
135 <td valign="top">the name of a file. Each line of this file is
136 taken to be an include pattern</td>
137 <td valign="top" align="center">No</td>
138 </tr>
139 <tr>
140 <td valign="top">excludes</td>
141 <td valign="top">comma- or space-separated list of patterns of files that must be
142 excluded. No files (except default excludes) are excluded when omitted.</td>
143 <td valign="top" align="center">No</td>
144 </tr>
145 <tr>
146 <td valign="top">excludesfile</td>
147 <td valign="top">the name of a file. Each line of this file is
148 taken to be an exclude pattern</td>
149 <td valign="top" align="center">No</td>
150 </tr>
151 <tr>
152 <td valign="top">defaultexcludes</td>
153 <td valign="top">indicates whether default excludes should be used or not
154 (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
155 <td valign="top" align="center">No</td>
156 </tr>
157 <tr>
158 <td valign="top">manifest</td>
159 <td valign="top">the manifest file to use.</td>
160 <td valign="top" align="center">No</td>
161 </tr>
162 <tr>
163 <td valign="top">update</td>
164 <td valign="top">indicates whether to update or overwrite
165 the destination file if it already exists. Default is &quot;false&quot;.</td>
166 <td valign="top" align="center">No</td>
167 </tr>
168 <tr>
169 <td valign="top">duplicate</td>
170 <td valign="top">behavior when a duplicate file is found. Valid values are &quot;add&quot;, &quot;preserve&quot;, and &quot;fail&quot;. The default value is &quot;add&quot;. </td>
171 <td valign="top" align="center">No</td>
172 </tr>
173 <tr>
174 <td valign="top">roundup</td>
175 <td valign="top">Whether the file modification times will be
176 rounded up to the next even number of seconds.<br>
177 Zip archives store file modification times with a granularity of
178 two seconds, so the times will either be rounded up or down. If
179 you round down, the archive will always seem out-of-date when you
180 rerun the task, so the default is to round up. Rounding up may
181 lead to a different type of problems like JSPs inside a web
182 archive that seem to be slightly more recent than precompiled
183 pages, rendering precompilation useless.<br>
184 Defaults to true. <em>Since Ant 1.6.2</em></td>
185 <td align="center" valign="top">No</td>
186 </tr>
187 <tr>
188 <td valign="top">level</td>
189 <td valign="top">Non-default level at which file compression should be
190 performed. Valid values range from 0 (no compression/fastest) to 9
191 (maximum compression/slowest). <em>Since Ant 1.7</em></td>
192 <td valign="top" align="center">No</td>
193 </tr>
194</table>
195<h3>Nested elements</h3>
196<h4>lib</h4>
197<p>The nested <code>lib</code> element specifies a <a
198href="../CoreTypes/fileset.html">FileSet</a>. All files included in this fileset will
199end up in the <code>WEB-INF/lib</code> directory of the war file.</p>
200<h4>classes</h4>
201<p>The nested <code>classes</code> element specifies a <a
202href="../CoreTypes/fileset.html">FileSet</a>. All files included in this fileset will
203end up in the <code>WEB-INF/classes</code> directory of the war file.</p>
204<h4>webinf</h4>
205<p>The nested <code>webinf</code> element specifies a <a
206href="../CoreTypes/fileset.html">FileSet</a>. All files included in this fileset will
207end up in the <code>WEB-INF</code> directory of the war file. If this
208fileset includes a file named <code>web.xml</code>, the file is
209ignored and you will get a warning.</p>
210<h4>metainf</h4>
211<p>The nested <code>metainf</code> element specifies a <a
212href="../CoreTypes/fileset.html">FileSet</a>. All files included in this fileset will
213end up in the <code>META-INF</code> directory of the war file. If this
214fileset includes a file named <code>MANIFEST.MF</code>, the file is
215ignored and you will get a warning.</p>
216<h3>Examples</h3>
217<p>Assume the following structure in the project's base directory:</p>
218<pre>
219thirdparty/libs/jdbc1.jar
220thirdparty/libs/jdbc2.jar
221build/main/com/myco/myapp/Servlet.class
222src/metadata/myapp.xml
223src/html/myapp/index.html
224src/jsp/myapp/front.jsp
225src/graphics/images/gifs/small/logo.gif
226src/graphics/images/gifs/large/logo.gif
227</pre>
228<p>then the war file <code>myapp.war</code> created with</p>
229<pre>
230&lt;war destfile=&quot;myapp.war&quot; webxml=&quot;src/metadata/myapp.xml&quot;&gt;
231 &lt;fileset dir=&quot;src/html/myapp&quot;/&gt;
232 &lt;fileset dir=&quot;src/jsp/myapp&quot;/&gt;
233 &lt;lib dir=&quot;thirdparty/libs&quot;&gt;
234 &lt;exclude name=&quot;jdbc1.jar&quot;/&gt;
235 &lt;/lib&gt;
236 &lt;classes dir=&quot;build/main&quot;/&gt;
237 &lt;zipfileset dir=&quot;src/graphics/images/gifs&quot;
238 prefix=&quot;images&quot;/&gt;
239&lt;/war&gt;
240</pre>
241<p>will consist of</p>
242<pre>
243WEB-INF/web.xml
244WEB-INF/lib/jdbc2.jar
245WEB-INF/classes/com/myco/myapp/Servlet.class
246META-INF/MANIFEST.MF
247index.html
248front.jsp
249images/small/logo.gif
250images/large/logo.gif
251</pre>
252<p>using Ant's default manifest file. The content of
253<code>WEB-INF/web.xml</code> is identical to
254<code>src/metadata/myapp.xml</code>.</p>
255
256<p>We regulary receive bug reports that this task is creating the WEB-INF
257directory, and thus it is our fault your webapp doesn't work. The cause
258of these complaints lies in WinZip, which turns an all upper-case
259directory into an all lower case one in a fit of helpfulness. Please check that
260<code>jar xvf yourwebapp.war</code> shows the same behaviour before filing another
261report.<br/>
262Winzip has an option allowing all uppercase names (which is off by default!). It can be enabled by:
263Menu "Options" -> "Configuration", "View" property/tab page, then "General" group box has an option called "Allow all uppercase file names".
264</p>
265
266
267
268</body>
269</html>
Note: See TracBrowser for help on using the repository browser.