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

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