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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Ant User Manual</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">warfile</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">webxml</td>
  31. <td valign="top">The deployment descriptor to use (WEB-INF/web.xml).</td>
  32. <td valign="top" align="center">Yes</td>
  33. </tr>
  34. <tr>
  35. <td valign="top">basedir</td>
  36. <td valign="top">the directory from which to jar the files.</td>
  37. <td valign="top" align="center">No</td>
  38. </tr>
  39. <tr>
  40. <td valign="top">compress</td>
  41. <td valign="top">Not only store data but also compress them, defaults to true</td>
  42. <td align="center" valign="top">No</td>
  43. </tr>
  44. <tr>
  45. <td valign="top">includes</td>
  46. <td valign="top">comma separated list of patterns of files that must be
  47. included. All files are included when omitted.</td>
  48. <td valign="top" align="center">No</td>
  49. </tr>
  50. <tr>
  51. <td valign="top">includesfile</td>
  52. <td valign="top">the name of a file. Each line of this file is
  53. taken to be an include pattern</td>
  54. <td valign="top" align="center">No</td>
  55. </tr>
  56. <tr>
  57. <td valign="top">excludes</td>
  58. <td valign="top">comma separated list of patterns of files that must be
  59. excluded. No files (except default excludes) are excluded when omitted.</td>
  60. <td valign="top" align="center">No</td>
  61. </tr>
  62. <tr>
  63. <td valign="top">excludesfile</td>
  64. <td valign="top">the name of a file. Each line of this file is
  65. taken to be an exclude pattern</td>
  66. <td valign="top" align="center">No</td>
  67. </tr>
  68. <tr>
  69. <td valign="top">defaultexcludes</td>
  70. <td valign="top">indicates whether default excludes should be used or not
  71. (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
  72. <td valign="top" align="center">No</td>
  73. </tr>
  74. <tr>
  75. <td valign="top">manifest</td>
  76. <td valign="top">the manifest file to use.</td>
  77. <td valign="top" align="center">No</td>
  78. </tr>
  79. <tr>
  80. <td valign="top">whenempty</td>
  81. <td valign="top">Behavior to use if no files match.</td>
  82. <td valign="top" align="center">No</td>
  83. </tr>
  84. </table>
  85. <h3>Nested elements</h3>
  86. <h4>lib</h4>
  87. <p>The nested <code>lib</code> element specifies a <a
  88. href="../CoreTypes/fileset.html">FileSet</a>. All files included in this fileset will
  89. end up in the <code>WEB-INF/lib</code> directory of the war file.</p>
  90. <h4>classes</h4>
  91. <p>The nested <code>classes</code> element specifies a <a
  92. href="../CoreTypes/fileset.html">FileSet</a>. All files included in this fileset will
  93. end up in the <code>WEB-INF/classes</code> directory of the war file.</p>
  94. <h4>webinf</h4>
  95. <p>The nested <code>webinf</code> element specifies a <a
  96. href="../CoreTypes/fileset.html">FileSet</a>. All files included in this fileset will
  97. end up in the <code>WEB-INF</code> directory of the war file. If this
  98. fileset includes a file named <code>web.xml</code>, the file is
  99. ignored and you will get a warning.</p>
  100. <h4>metainf</h4>
  101. <p>The nested <code>metainf</code> element specifies a <a
  102. href="../CoreTypes/fileset.html">FileSet</a>. All files included in this fileset will
  103. end up in the <code>META-INF</code> directory of the war file. If this
  104. fileset includes a file named <code>MANIFEST.MF</code>, the file is
  105. ignored and you will get a warning.</p>
  106. <h3>Examples</h3>
  107. <p>Assume the following structure in the project's base directory:</p>
  108. <pre>
  109. thirdparty/libs/jdbc1.jar
  110. thirdparty/libs/jdbc2.jar
  111. build/main/com/myco/myapp/Servlet.class
  112. src/metadata/myapp.xml
  113. src/html/myapp/index.html
  114. src/jsp/myapp/front.jsp
  115. src/graphics/images/gifs/small/logo.gif
  116. src/graphics/images/gifs/large/logo.gif
  117. </pre>
  118. then the war file <code>myapp.war</code> created with
  119. <pre>
  120. &lt;war warfile=&quot;myapp.war&quot; webxml=&quot;src/metadata/myapp.xml&quot;&gt;
  121. &lt;fileset dir=&quot;src/html/myapp&quot;/&gt;
  122. &lt;fileset dir=&quot;src/jsp/myapp&quot;/&gt;
  123. &lt;lib dir=&quot;thirdparty/libs&quot;&gt;
  124. &lt;exclude name=&quot;jdbc1.jar&quot;/&gt;
  125. &lt;/lib&gt;
  126. &lt;classes dir=&quot;build/main&quot;/&gt;
  127. &lt;zipfileset dir=&quot;src/graphics/images/gifs&quot;
  128. prefix=&quot;images&quot;/&gt;
  129. &lt;/war&gt;
  130. </pre>
  131. will consist of
  132. <pre>
  133. WEB-INF/web.xml
  134. WEB-INF/lib/jdbc2.jar
  135. WEB-INF/classes/com/myco/myapp/Servlet.class
  136. META-INF/MANIFEST.MF
  137. index.html
  138. front.jsp
  139. images/small/logo.gif
  140. images/large/logo.gif
  141. </pre>
  142. using Ant's default manifest file. The content of
  143. <code>WEB-INF/web.xml</code> is identical to
  144. <code>src/metadata/myapp.xml</code>.
  145. <hr>
  146. <p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
  147. Reserved.</p>
  148. </body>
  149. </html>