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 6.9 KiB

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