Debian Codegraph @

manual/Tasks/manifest.html

raw
1 <!DOCTYPE html>
2 <!--
3 Licensed to the Apache Software Foundation (ASF) under one or more
4 contributor license agreements. See the NOTICE file distributed with
5 this work for additional information regarding copyright ownership.
6 The ASF licenses this file to You under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with
8 the License. You may obtain a copy of the License at
9
10 https://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 -->
18 <html lang="en">
19
20 <head>
21 <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
22 <title>Manifest Task</title>
23 </head>
24
25 <body>
26
27 <h2 id="manifest">Manifest</h2>
28 <h3>Description</h3>
29 <p>Creates a manifest file.</p>
30
31 <p>This task can be used to write a Manifest file, optionally replacing or updating an existing
32 file.</p>
33
34 <p>Manifests are processed according to
35 the <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html" target="_top">Jar
36 file specification</a>. Specifically, a manifest element consists of a set of attributes and
37 sections. These sections in turn may contain attributes. Note in particular that this may result in
38 manifest lines greater than 72 bytes being wrapped and continued on the next line.</p>
39
40 <p>The Apache Ant team regularly gets complaints that this task in generating invalid manifests. By
41 and large, this is not the case: we believe that we are following the specification to the
42 letter. The usual problem is that some third party manifest reader is not following the same
43 specification as well as they think they should; we cannot generate invalid manifest files just
44 because one single application is broken. Java ME runtimes appear to be particularly
45 troublesome.</p>
46
47 <p>If you find that Ant generates manifests incompatible with your runtime, take a manifest it has
48 built, fix it up however you need and switch to using the <a href="zip.html">zip</a> task to create
49 the JAR, feeding in the hand-crafted manifest.</p>
50
51 <h3>Parameters</h3>
52 <table class="attr">
53 <tr>
54 <th scope="col">Attribute</th>
55 <th scope="col">Description</th>
56 <th scope="col">Required</th>
57 </tr>
58 <tr>
59 <td>file</td>
60 <td>the manifest-file to create/update.</td>
61 <td>Yes</td>
62 </tr>
63 <tr>
64 <td>mode</td>
65 <td>One of <q>update</q> or <q>replace</q>.</td>
66 <td>No; default is <q>replace</q></td>
67 </tr>
68 <tr>
69 <td>encoding</td>
70 <td>The encoding used to read the existing manifest when updating. The task will always use
71 UTF-8 when writing the manifest.</td>
72 <td>No; defaults to UTF-8 encoding</td>
73 </tr>
74 <tr>
75 <td>mergeClassPathAttributes</td>
76 <td>Whether to merge the <code>Class-Path</code> attributes found in different manifests (if
77 updating). If <q>false</q>, only the attribute of the most recent manifest will be
78 preserved. <em>Since Ant 1.8.0</em>.<br/>Unless you also set <var>flattenAttributes</var>
79 to <q>true</q> this may result in manifests containing multiple <code>Class-Path</code>
80 attributes which violates the manifest specification.</td>
81 <td>No; default is <q>false</q></td>
82 </tr>
83 <tr>
84 <td>flattenAttributes</td>
85 <td>Whether to merge attributes occurring more than once in a section (this can only happen for
86 the <code>Class-Path</code> attribute) into a single attribute. <em>Since Ant
87 1.8.0</em>.</td>
88 <td>No; default is <q>false</q></td>
89 </tr>
90 </table>
91
92 <h3>Parameters specified as nested elements</h3>
93 <h4 id="attribute">attribute</h4>
94 <p>One attribute for the manifest file. Those attributes that are not nested into a section will be
95 added to the main section.</p>
96 <table class="attr">
97 <tr>
98 <th scope="col">Attribute</th>
99 <th scope="col">Description</th>
100 <th scope="col">Required</th>
101 </tr>
102 <tr>
103 <td>name</td>
104 <td>the name of the attribute, must match the regexp <q>[A-Za-z0-9][A-Za-z0-9-_]*</q>.
105 </td>
106 <td>Yes</td>
107 </tr>
108 <tr>
109 <td>value</td>
110 <td>the value of the attribute.</td>
111 <td>Yes</td>
112 </tr>
113 </table>
114
115 <h4>section</h4>
116 <p>A manifest section&mdash;you can nest <a href="#attribute">attribute</a> elements into
117 sections.</p>
118
119 <table class="attr">
120 <tr>
121 <th scope="col">Attribute</th>
122 <th scope="col">Description</th>
123 <th scope="col">Required</th>
124 </tr>
125 <tr>
126 <td>name</td>
127 <td>the name of the section.</td>
128 <td>No, defaults to the main section</td>
129 </tr>
130 </table>
131
132 <h3>Examples</h3>
133
134 <p>Create or replace 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
141 <pre>
142 &lt;manifest file=&quot;MANIFEST.MF&quot;&gt;
143 &lt;attribute name=&quot;Built-By&quot; value=&quot;${user.name}&quot;/&gt;
144 &lt;section name=&quot;common&quot;&gt;
145 &lt;attribute name=&quot;Specification-Title&quot; value=&quot;Example&quot;/&gt;
146 &lt;attribute name=&quot;Specification-Version&quot; value=&quot;${version}&quot;/&gt;
147 &lt;attribute name=&quot;Specification-Vendor&quot; value=&quot;Example Organization&quot;/&gt;
148 &lt;attribute name=&quot;Implementation-Title&quot; value=&quot;common&quot;/&gt;
149 &lt;attribute name=&quot;Implementation-Version&quot; value=&quot;${version} ${TODAY}&quot;/&gt;
150 &lt;attribute name=&quot;Implementation-Vendor&quot; value=&quot;Example Corp.&quot;/&gt;
151 &lt;/section&gt;
152 &lt;section name=&quot;common/class1.class&quot;&gt;
153 &lt;attribute name=&quot;Sealed&quot; value=&quot;false&quot;/&gt;
154 &lt;/section&gt;
155 &lt;/manifest&gt;</pre>
156
157 <p>The manifest produced by the above would look like this:</p>
158
159 <pre>
160 Manifest-Version: 1.0
161 Built-By: bodewig
162 Created-By: Apache Ant 1.9
163
164 Name: common
165 Specification-Title: Example
166 Specification-Vendor: Example Organization
167 Implementation-Vendor: Example Corp.
168 Specification-Version: 1.2
169 Implementation-Version: 1.2 September 10, 2013
170 Implementation-Title: common
171
172 Name: common/class1.class
173 Sealed: false</pre>
174
175 </body>
176 </html>