You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

war.html 8.9 KiB

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