source: other-projects/trunk/realistic-books/packages/AntInstaller/web/manual1.6.2/manual/CoreTasks/war.html@ 19253

Last change on this file since 19253 was 19253, checked in by davidb, 15 years ago

Establishing a source code repository for Veronica's Realistic Book's software

File size: 8.3 KB
Line 
1<html>
2
3<head>
4<meta http-equiv="Content-Language" content="en-us">
5<title>WAR Task</title>
6<link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
7</head>
8
9<body>
10
11<h2><a name="war">War</a></h2>
12<h3>Description</h3>
13<p>An extension of the <a href="jar.html">Jar</a> task with special
14treatment for files that should end up in the
15<code>WEB-INF/lib</code>, <code>WEB-INF/classes</code> or
16<code>WEB-INF</code> directories of the Web Application Archive.</p>
17<p>(The War task is a shortcut for specifying the particular layout of a WAR file.
18The same thing can be accomplished by using the <i>prefix</i> and <i>fullpath</i>
19attributes of zipfilesets in a Zip or Jar task.)</p>
20<p>The extended zipfileset element from the zip task (with attributes <i>prefix</i>, <i>fullpath</i>, and <i>src</i>) is available in the War task.</p>
21
22<h3>Parameters</h3>
23<table border="1" cellpadding="2" cellspacing="0">
24 <tr>
25 <td valign="top"><b>Attribute</b></td>
26 <td valign="top"><b>Description</b></td>
27 <td align="center" valign="top"><b>Required</b></td>
28 </tr>
29 <tr>
30 <td valign="top">destfile</td>
31 <td valign="top">the WAR file to create.</td>
32 <td align="center" valign="top" rowspan="2">Exactly one of the two.</td>
33 </tr>
34 <tr>
35 <td valign="top">warfile</td>
36 <td valign="top"><i>Deprecated<i> name of the file to create
37 -use <tt>destfile</tt> instead.</td>
38 </tr>
39 <tr>
40 <td valign="top">webxml</td>
41 <td valign="top">The deployment descriptor to use (WEB-INF/web.xml).</td>
42 <td valign="top" align="center">Yes, unless update is set to true</td>
43 </tr>
44 <tr>
45 <td valign="top">basedir</td>
46 <td valign="top">the directory from which to jar the files.</td>
47 <td valign="top" align="center">No</td>
48 </tr>
49 <tr>
50 <td valign="top">compress</td>
51 <td valign="top">Not only store data but also compress them,
52 defaults to true. Unless you set the <em>keepcompression</em>
53 attribute to false, this will apply to the entire archive, not
54 only the files you've added while updating.</td>
55 <td align="center" valign="top">No</td>
56 </tr>
57 <tr>
58 <td valign="top">keepcompression</td>
59 <td valign="top">For entries coming from existing archives (like
60 nested <em>zipfileset</em>s or while updating the archive), keep
61 the compression as it has been originally instead of using the
62 <em>compress</em> attribute. Defaults false. <em>Since Ant
63 1.6</em></td>
64 <td align="center" valign="top">No</td>
65 </tr>
66 <tr>
67 <td valign="top">encoding</td>
68 <td valign="top">The character encoding to use for filenames
69 inside the archive. Defaults to UTF8. <strong>It is not
70 recommended to change this value as the created archive will most
71 likely be unreadable for Java otherwise.</strong></td>
72 <td align="center" valign="top">No</td>
73 </tr>
74 <tr>
75 <td valign="top">filesonly</td>
76 <td valign="top">Store only file entries, defaults to false</td>
77 <td align="center" valign="top">No</td>
78 </tr>
79 <tr>
80 <td valign="top">includes</td>
81 <td valign="top">comma- or space-separated list of patterns of files that must be
82 included. All files are included when omitted.</td>
83 <td valign="top" align="center">No</td>
84 </tr>
85 <tr>
86 <td valign="top">includesfile</td>
87 <td valign="top">the name of a file. Each line of this file is
88 taken to be an include pattern</td>
89 <td valign="top" align="center">No</td>
90 </tr>
91 <tr>
92 <td valign="top">excludes</td>
93 <td valign="top">comma- or space-separated list of patterns of files that must be
94 excluded. No files (except default excludes) are excluded when omitted.</td>
95 <td valign="top" align="center">No</td>
96 </tr>
97 <tr>
98 <td valign="top">excludesfile</td>
99 <td valign="top">the name of a file. Each line of this file is
100 taken to be an exclude pattern</td>
101 <td valign="top" align="center">No</td>
102 </tr>
103 <tr>
104 <td valign="top">defaultexcludes</td>
105 <td valign="top">indicates whether default excludes should be used or not
106 (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
107 <td valign="top" align="center">No</td>
108 </tr>
109 <tr>
110 <td valign="top">manifest</td>
111 <td valign="top">the manifest file to use.</td>
112 <td valign="top" align="center">No</td>
113 </tr>
114 <tr>
115 <td valign="top">update</td>
116 <td valign="top">indicates whether to update or overwrite
117 the destination file if it already exists. Default is &quot;false&quot;.</td>
118 <td valign="top" align="center">No</td>
119 </tr>
120 <tr>
121 <td valign="top">duplicate</td>
122 <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>
123 <td valign="top" align="center">No</td>
124 </tr>
125 <tr>
126 <td valign="top">roundup</td>
127 <td valign="top">Whether the file modification times will be
128 rounded up to the next even number of seconds.<br>
129 Zip archives store file modification times with a granularity of
130 two seconds, so the times will either be rounded up or down. If
131 you round down, the archive will always seem out-of-date when you
132 rerun the task, so the default is to round up. Rounding up may
133 lead to a different type of problems like JSPs inside a web
134 archive that seem to be slightly more recent than precompiled
135 pages, rendering precompilation useless.<br>
136 Defaults to true. <em>Since Ant 1.6.2</em></td>
137 <td align="center" valign="top">No</td>
138 </tr>
139</table>
140<h3>Nested elements</h3>
141<h4>lib</h4>
142<p>The nested <code>lib</code> element specifies a <a
143href="../CoreTypes/fileset.html">FileSet</a>. All files included in this fileset will
144end up in the <code>WEB-INF/lib</code> directory of the war file.</p>
145<h4>classes</h4>
146<p>The nested <code>classes</code> element specifies a <a
147href="../CoreTypes/fileset.html">FileSet</a>. All files included in this fileset will
148end up in the <code>WEB-INF/classes</code> directory of the war file.</p>
149<h4>webinf</h4>
150<p>The nested <code>webinf</code> element specifies a <a
151href="../CoreTypes/fileset.html">FileSet</a>. All files included in this fileset will
152end up in the <code>WEB-INF</code> directory of the war file. If this
153fileset includes a file named <code>web.xml</code>, the file is
154ignored and you will get a warning.</p>
155<h4>metainf</h4>
156<p>The nested <code>metainf</code> element specifies a <a
157href="../CoreTypes/fileset.html">FileSet</a>. All files included in this fileset will
158end up in the <code>META-INF</code> directory of the war file. If this
159fileset includes a file named <code>MANIFEST.MF</code>, the file is
160ignored and you will get a warning.</p>
161<h3>Examples</h3>
162<p>Assume the following structure in the project's base directory:</p>
163<pre>
164thirdparty/libs/jdbc1.jar
165thirdparty/libs/jdbc2.jar
166build/main/com/myco/myapp/Servlet.class
167src/metadata/myapp.xml
168src/html/myapp/index.html
169src/jsp/myapp/front.jsp
170src/graphics/images/gifs/small/logo.gif
171src/graphics/images/gifs/large/logo.gif
172</pre>
173then the war file <code>myapp.war</code> created with
174<pre>
175&lt;war destfile=&quot;myapp.war&quot; webxml=&quot;src/metadata/myapp.xml&quot;&gt;
176 &lt;fileset dir=&quot;src/html/myapp&quot;/&gt;
177 &lt;fileset dir=&quot;src/jsp/myapp&quot;/&gt;
178 &lt;lib dir=&quot;thirdparty/libs&quot;&gt;
179 &lt;exclude name=&quot;jdbc1.jar&quot;/&gt;
180 &lt;/lib&gt;
181 &lt;classes dir=&quot;build/main&quot;/&gt;
182 &lt;zipfileset dir=&quot;src/graphics/images/gifs&quot;
183 prefix=&quot;images&quot;/&gt;
184&lt;/war&gt;
185</pre>
186will consist of
187<pre>
188WEB-INF/web.xml
189WEB-INF/lib/jdbc2.jar
190WEB-INF/classes/com/myco/myapp/Servlet.class
191META-INF/MANIFEST.MF
192index.html
193front.jsp
194images/small/logo.gif
195images/large/logo.gif
196</pre>
197using Ant's default manifest file. The content of
198<code>WEB-INF/web.xml</code> is identical to
199<code>src/metadata/myapp.xml</code>.
200
201We regulary receive bug reports that this task is creating the WEB-INF
202directory, and thus it is our fault your webapp doesn't work. The cause
203of these complaints lies in WinZip, which turns an all upper-case
204directory into an all lower case one in a fit of helpfulness. Please check that
205jar xvf yourwebapp.war shows the same behaviour before filing another
206report.
207
208<hr>
209<p align="center">Copyright &copy; 2000-2004 The Apache Software Foundation. All rights
210Reserved.</p>
211
212</body>
213</html>
214
Note: See TracBrowser for help on using the repository browser.