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.

manifest.html 7.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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>Manifest Task</title>
  20. </head>
  21. <body>
  22. <h2><a name="manifest">Manifest</a></h2>
  23. <h3>Description</h3>
  24. <p>Creates a manifest file.</p>
  25. <p>This task can be used to write a Manifest file, optionally
  26. replacing or updating an existing file.</p>
  27. <p>Manifests are processed according to the
  28. <a href="http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html">Jar
  29. file specification.</a>. Specifically, a manifest element consists of
  30. a set of attributes and sections. These sections in turn may contain
  31. attributes. Note in particular that this may result in manifest lines
  32. greater than 72 bytes being wrapped and continued on the next
  33. line.</p>
  34. <p>
  35. The Ant team regularly gets complaints that this task in generating invalid
  36. manifests. By and large, this is not the case: we believe that we are following
  37. the specification to the letter. The usual problem is that some third party
  38. manifest reader is not following the same specification as well as they think
  39. they should; we cannot generate invalid manifest files just because one
  40. single application is broken. J2ME runtimes appear to be particularly troublesome.
  41. </p>
  42. <p>
  43. If you find that Ant generates manifests incompatible with your runtime, take
  44. a manifest it has built, fix it up however you need and switch to using the &lt;zip&gt
  45. task to create the JAR, feeding in the hand-crafted manifest.
  46. </p>
  47. <h3>Parameters</h3>
  48. <table border="1" cellpadding="2" cellspacing="0">
  49. <tr>
  50. <td valign="top"><b>Attribute</b></td>
  51. <td valign="top"><b>Description</b></td>
  52. <td align="center" valign="top"><b>Required</b></td>
  53. </tr>
  54. <tr>
  55. <td valign="top">file</td>
  56. <td valign="top">the manifest-file to create/update.</td>
  57. <td valign="top" align="center">Yes</td>
  58. </tr>
  59. <tr>
  60. <td valign="top">mode</td>
  61. <td valign="top">One of "update" or "replace", default is "replace".</td>
  62. <td valign="top" align="center">No</td>
  63. </tr>
  64. <tr>
  65. <td valign="top">encoding</td>
  66. <td valign="top">The encoding used to read the existing manifest
  67. when updating. The task will always use UTF-8 when writing the
  68. manifest.</td>
  69. <td valign="top" align="center">No, defaults to UTF-8 encoding.</td>
  70. </tr>
  71. <tr>
  72. <td valign="top">mergeClassPathAttributes</td>
  73. <td valign="top">Whether to merge the Class-Path attributes found
  74. in different manifests (if updating). If false, only the
  75. attribute of the most recent manifest will be preserved.
  76. <em>Since Ant 1.8.0</em>.
  77. <br/>unless you also set flattenAttributes to true this may
  78. result in manifests containing multiple Class-Path attributes
  79. which violates the manifest specification.</td>
  80. <td align="center" valign="top">No, default is false</td>
  81. </tr>
  82. <tr>
  83. <td valign="top">flattenAttributes</td>
  84. <td valign="top">Whether to merge attributes occuring more than
  85. once in a section (this can only happen for the Class-Path
  86. attribute) into a single attribute.
  87. <em>Since Ant 1.8.0</em>.</td>
  88. <td align="center" valign="top">No, default is false</td>
  89. </tr>
  90. </table>
  91. <h3>Nested elements</h3>
  92. <h4><a name="attribute">attribute</a></h4>
  93. <p>One attribute for the manifest file. Those attributes that are
  94. not nested into a section will be added to the "Main" section.</p>
  95. <table border="1" cellpadding="2" cellspacing="0">
  96. <tr>
  97. <td valign="top"><b>Attribute</b></td>
  98. <td valign="top"><b>Description</b></td>
  99. <td align="center" valign="top"><b>Required</b></td>
  100. </tr>
  101. <tr>
  102. <td valign="top">name</td>
  103. <td valign="top">the name of the attribute, <br>
  104. must match the regexp <tt>[A-Za-z0-9][A-Za-z0-9-_]*</tt>.
  105. </td>
  106. <td valign="top" align="center">Yes</td>
  107. </tr>
  108. <tr>
  109. <td valign="top">value</td>
  110. <td valign="top">the value of the attribute.</td>
  111. <td valign="top" align="center">Yes</td>
  112. </tr>
  113. </table>
  114. <h4>section</h4>
  115. <p>A manifest section - you can nest <a
  116. href="#attribute">attribute</a> elements into sections.</p>
  117. <table border="1" cellpadding="2" cellspacing="0">
  118. <tr>
  119. <td valign="top"><b>Attribute</b></td>
  120. <td valign="top"><b>Description</b></td>
  121. <td align="center" valign="top"><b>Required</b></td>
  122. </tr>
  123. <tr>
  124. <td valign="top">name</td>
  125. <td valign="top">the name of the section.</td>
  126. <td valign="top" align="center">No, if omitted it will be assumed
  127. to be the main section.</td>
  128. </tr>
  129. </table>
  130. <h3>Examples</h3>
  131. <pre>
  132. &lt;manifest file=&quot;MANIFEST.MF&quot;&gt;
  133. &lt;attribute name=&quot;Built-By&quot; value=&quot;${user.name}&quot;/&gt;
  134. &lt;section name=&quot;common&quot;&gt;
  135. &lt;attribute name=&quot;Specification-Title&quot; value=&quot;Example&quot;/&gt;
  136. &lt;attribute name=&quot;Specification-Version&quot; value=&quot;${version}&quot;/&gt;
  137. &lt;attribute name=&quot;Specification-Vendor&quot; value=&quot;Example Organization&quot;/&gt;
  138. &lt;attribute name=&quot;Implementation-Title&quot; value=&quot;common&quot;/&gt;
  139. &lt;attribute name=&quot;Implementation-Version&quot; value=&quot;${version} ${TODAY}&quot;/&gt;
  140. &lt;attribute name=&quot;Implementation-Vendor&quot; value=&quot;Example Corp.&quot;/&gt;
  141. &lt;/section&gt;
  142. &lt;section name=&quot;common/class1.class&quot;&gt;
  143. &lt;attribute name=&quot;Sealed&quot; value=&quot;false&quot;/&gt;
  144. &lt;/section&gt;
  145. &lt;/manifest&gt;
  146. </pre>
  147. <p>Creates or replaces the file MANIFEST.MF. Note that the Built-By
  148. attribute will take the value of the Ant property ${user.name}. The
  149. same is true for the ${version} and ${TODAY} properties. This example
  150. produces a MANIFEST.MF that contains
  151. <a href="http://java.sun.com/j2se/1.5.0/docs/guide/versioning/">package
  152. version identification</a> for the package <code>common</code>.</p>
  153. <p>The manifest produced by the above would look like this:</p>
  154. <pre><code>Manifest-Version: 1.0
  155. Built-By: bodewig
  156. Created-By: Apache Ant 1.7
  157. Name: common
  158. Specification-Title: Example
  159. Specification-Vendor: Example Organization
  160. Implementation-Vendor: Example Corp.
  161. Specification-Version: 1.2
  162. Implementation-Version: 1.2 February 19 2006
  163. Implementation-Title: common
  164. Name: common/class1.class
  165. Sealed: false
  166. </code></pre>
  167. </body>
  168. </html>