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