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.

ear.html 11 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <!--
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <html>
  16. <head>
  17. <meta http-equiv="Content-Language" content="en-us">
  18. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  19. <title>EAR Task</title>
  20. </head>
  21. <body>
  22. <h2 id="ear">Ear</h2>
  23. <h3>Description</h3>
  24. <p>An extension of the <a href="jar.html">Jar</a> task with special treatment for files that should
  25. end up in an Enterprise Application archive.</p>
  26. <p>(The <code>Ear</code> task is a shortcut for specifying the particular layout of a EAR file. The
  27. same thing can be accomplished by using the <var>prefix</var> and <var>fullpath</var> attributes of
  28. zipfilesets in a <code>Zip</code> or <code>Jar</code> task.)</p>
  29. <p>The extended zipfileset element from the <code>Zip</code> task (with
  30. attributes <var>prefix</var>, <var>fullpath</var>, and <var>src</var>) is available in
  31. the <code>Ear</code> task.</p>
  32. <p><strong>Please note that the zip format allows multiple files of the same fully-qualified name to
  33. exist within a single archive. This has been documented as causing various problems for
  34. unsuspecting users. If you wish to avoid this behavior you must set the <var>duplicate</var>
  35. attribute to a value other than its default, <q>add</q>.</strong></p>
  36. <h3>Parameters</h3>
  37. <table class="attr">
  38. <tr>
  39. <th>Attribute</th>
  40. <th>Description</th>
  41. <th>Required</th>
  42. </tr>
  43. <tr>
  44. <td>destfile</td>
  45. <td>the EAR file to create.</td>
  46. <td>Yes</td>
  47. </tr>
  48. <tr>
  49. <td>appxml</td>
  50. <td>The deployment descriptor to use (<samp>META-INF/application.xml</samp>).</td>
  51. <td>Yes, unless <var>update</var> is set to <q>true</q></td>
  52. </tr>
  53. <tr>
  54. <td>basedir</td>
  55. <td>the directory from which to jar the files.</td>
  56. <td>No</td>
  57. </tr>
  58. <tr>
  59. <td>compress</td>
  60. <td>Not only store data but also compress them. Unless you set the <var>keepcompression</var>
  61. attribute to <q>false</q>, this will apply to the entire archive, not only the files you've
  62. added while updating.</td>
  63. <td>No; defaults to <q>true</q></td>
  64. </tr>
  65. <tr>
  66. <td>keepcompression</td>
  67. <td>For entries coming from existing archives (like nested <code>zipfileset</code>s or while
  68. updating the archive), keep the compression as it has been originally instead of using the
  69. <var>compress</var> attribute. <em>Since Apache Ant 1.6</em></td>
  70. <td>No; defaults to <q>false</q></td>
  71. </tr>
  72. <tr>
  73. <td>encoding</td>
  74. <td>The character encoding to use for filenames inside the archive. <strong>It is not
  75. recommended to change this value as the created archive will most likely be unreadable for
  76. Java otherwise.</strong> <br/>See also the <a href="zip.html#encoding">discussion in the zip
  77. task page</a></td>
  78. <td>No; defaults to <q>UTF8</q></td>
  79. </tr>
  80. <tr>
  81. <td>filesonly</td>
  82. <td>Store only file entries.</td>
  83. <td>No; defaults to <q>false</q></td>
  84. </tr>
  85. <tr>
  86. <td>includes</td>
  87. <td>comma- or space-separated list of patterns of files that must be included.</td>
  88. <td>No; defaults to all (<q>**</q>)</td>
  89. </tr>
  90. <tr>
  91. <td>includesfile</td>
  92. <td>name of a file. Each line of this file is taken to be an include pattern.</td>
  93. <td>No</td>
  94. </tr>
  95. <tr>
  96. <td>excludes</td>
  97. <td>comma- or space-separated list of patterns of files that must be excluded.</td>
  98. <td>No; defaults to default excludes or none if <var>defaultexcludes</var> is <q>no</q></td>
  99. </tr>
  100. <tr>
  101. <td>excludesfile</td>
  102. <td>name of a file. Each line of this file is taken to be an exclude pattern.</td>
  103. <td>No</td>
  104. </tr>
  105. <tr>
  106. <td>defaultexcludes</td>
  107. <td>indicates whether default excludes should be used or not (<q>yes|no</q>).</td>
  108. <td>No; defaults to <q>yes</q></td>
  109. </tr>
  110. <tr>
  111. <td>manifest</td>
  112. <td>the manifest file to use.</td>
  113. <td>No</td>
  114. </tr>
  115. <tr>
  116. <td>filesetmanifest</td>
  117. <td>behavior when a manifest file is found in a <code>zipfileset</code>
  118. or <code>zipgroupfileset</code> file. Valid values are <q>skip</q>, <q>merge</q>,
  119. and <q>mergewithoutmain</q>. <q>merge</q> will merge all of the manifests together, and merge
  120. this into any other specified manifests. <q>mergewithoutmain</q> merges everything but the Main
  121. section of the manifests.</td>
  122. <td>No; defaults to <q>skip</q></td>
  123. </tr>
  124. <tr>
  125. <td>whenmanifestonly</td>
  126. <td>behavior when no files match. Valid values are <q>fail</q>, <q>skip</q>,
  127. and <q>create</q>.</td>
  128. <td>No; defaults to <q>create</q></td>
  129. </tr>
  130. <tr>
  131. <td>manifestencoding</td>
  132. <td>The encoding used to read the JAR manifest, when a manifest file is specified.</td>
  133. <td>No; defaults to default JVM character encoding</td>
  134. </tr>
  135. <tr>
  136. <td>index</td>
  137. <td>whether to create
  138. an <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#JAR_Index">index
  139. list</a> to speed up classloading. This is a JDK 1.3+ specific feature. Unless you specify
  140. additional jars with nested <a href="jar.html#indexjars"><code>indexjars</code></a> elements,
  141. only the contents of this jar will be included in the index.</td>
  142. <td>No; defaults to <q>false</q></td>
  143. </tr>
  144. <tr>
  145. <td>indexMetaInf</td>
  146. <td>whether to include <samp>META-INF</samp> and its children in the index. Doesn't have any
  147. effect if <var>index</var> is false.<br/>Oracle's jar implementation used to skip
  148. the <samp>META-INF</samp> directory and Ant followed that example. The behavior has been
  149. changed with <a href="https://bugs.openjdk.java.net/browse/JDK-4408526">Java 5</a>. In order
  150. to avoid problems with Ant generated jars on Java 1.4 or earlier, Ant will not
  151. include <samp>META-INF</samp> unless explicitly asked to.<br/><em>Since Ant 1.8.0</em>.</td>
  152. <td>No; defaults to <q>false</q></td>
  153. </tr>
  154. <tr>
  155. <td>update</td>
  156. <td>indicates whether to update or overwrite the destination file if it already exists.</td>
  157. <td>No; default is <q>false</q></td>
  158. </tr>
  159. <tr>
  160. <td>duplicate</td>
  161. <td>behavior when a duplicate file is found. Valid values are <q>add</q>, <q>preserve</q>,
  162. and <q>fail</q>.</td>
  163. <td>No; default is <q>add</q></td>
  164. </tr>
  165. <tr>
  166. <td>roundup</td>
  167. <td>Whether the file modification times will be rounded up to the next even number of
  168. seconds.<br/>Zip archives store file modification times with a granularity of 2 seconds, so
  169. the times will either be rounded up or down. If you round down, the archive will always seem
  170. out-of-date when you rerun the task, so the default is to round up. Rounding up may lead to a
  171. different type of problems like JSPs inside a web archive that seem to be slightly more recent
  172. than precompiled pages, rendering precompilation useless.<br/><em>Since Ant 1.6.2</em></td>
  173. <td>No; defaults to <q>true</q></td>
  174. </tr>
  175. <tr>
  176. <td>level</td>
  177. <td>Non-default level at which file compression should be performed. Valid values range
  178. from <q>0</q> (no compression/fastest) to <q>9</q> (maximum compression/slowest). <em>Since Ant
  179. 1.7</em></td>
  180. <td>No</td>
  181. </tr>
  182. <tr>
  183. <td>preserve0permissions</td>
  184. <td>when updating an archive or adding entries from a different archive Ant will assume that a
  185. Unix permissions value of 0 (nobody is allowed to do anything to the file/directory) means
  186. that the permissions haven't been stored at all rather than real permissions and will instead
  187. apply its own default values.<br/> Set this attribute to <q>true</q> if you really want to
  188. preserve the original permission field. <em>Since Ant 1.8.0</em>
  189. </td>
  190. <td>No; default is <q>false</q></td>
  191. </tr>
  192. <tr>
  193. <td>useLanguageEncodingFlag</td>
  194. <td>Whether to set the language encoding flag if the encoding is UTF-8. This setting doesn't
  195. have any effect if the encoding is not UTF-8. <em>Since Ant 1.8.0</em>.<br/>See also
  196. the <a href="zip.html#encoding">discussion in the zip task page</a></td>
  197. <td>No; default is <q>true</q></td>
  198. </tr>
  199. <tr>
  200. <td>createUnicodeExtraFields</td>
  201. <td>Whether to create Unicode extra fields to store the file names a second time inside the
  202. entry's metadata.<br/>Possible values are <q>never</q>, <q>always</q>
  203. and <q>not-encodeable</q> which will only add Unicode extra fields if the file name cannot be
  204. encoded using the specified encoding. <em>Since Ant 1.8.0</em>. <br/>See also
  205. the <a href="zip.html#encoding">discussion in the zip task page</a></td>
  206. <td>No; default is <q>never</q></td>
  207. </tr>
  208. <tr>
  209. <td>fallbacktoUTF8</td>
  210. <td>Whether to use UTF-8 and the language encoding flag instead of the specified encoding if a
  211. file name cannot be encoded using the specified encoding. <em>Since Ant 1.8.0</em>.<br/>See
  212. also the <a href="zip.html#encoding">discussion in the zip task page</a></td>
  213. <td>No; default is <q>false</q></td>
  214. </tr>
  215. <tr>
  216. <td>mergeClassPathAttributes</td>
  217. <td>Whether to merge the <code>Class-Path</code> attributes found in different manifests (if
  218. merging manifests). If <q>false</q>, only the attribute of the last merged manifest will be
  219. preserved. <em>Since Ant 1.8.0</em>.<br/>unless you also set <var>flattenAttributes</var>
  220. to <q>true</q> this may result in manifests containing multiple <code>Class-Path</code>
  221. attributes which violates the manifest specification.</td>
  222. <td>No; default is <q>false</q></td>
  223. </tr>
  224. <tr>
  225. <td>flattenAttributes</td>
  226. <td>Whether to merge attributes occurring more than once in a section (this can only happen for
  227. the <code>Class-Path</code> attribute) into a single attribute. <em>Since Ant
  228. 1.8.0</em>.</td>
  229. <td>No; default is <q>false</q></td>
  230. </tr>
  231. <tr>
  232. <td>zip64Mode</td>
  233. <td>When to use Zip64 extensions for entries. The possible values
  234. are <q>never</q>, <q>always</q> and <q>as-needed</q>. <em>Since Ant 1.9.1</em>.<br/>See also
  235. the <a href="zip.html#zip64">discussion in the zip task page</a></td>
  236. <td>No; default is <q>never</q></td>
  237. </tr>
  238. </table>
  239. <h3>Nested elements</h3>
  240. <h4>metainf</h4>
  241. <p>The nested <code>metainf</code> element specifies
  242. a <a href="../Types/fileset.html">FileSet</a>. All files included in this fileset will end up in
  243. the <samp>META-INF</samp> directory of the ear file. If this fileset includes a file
  244. named <samp>MANIFEST.MF</samp>, the file is ignored and you will get a warning.</p>
  245. <h4>manifest, indexjars, service</h4>
  246. <p>These are inherited from <a href="jar.html">&lt;jar&gt;</a></p>
  247. <h2>Example</h2>
  248. <pre>
  249. &lt;ear destfile=&quot;${build.dir}/myapp.ear&quot; appxml=&quot;${src.dir}/metadata/application.xml&quot;&gt;
  250. &lt;fileset dir=&quot;${build.dir}&quot; includes=&quot;*.jar,*.war&quot;/&gt;
  251. &lt;/ear&gt;</pre>
  252. </body>
  253. </html>