| 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—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 |
<manifest file="MANIFEST.MF"> |
| 143 |
<attribute name="Built-By" value="${user.name}"/> |
| 144 |
<section name="common"> |
| 145 |
<attribute name="Specification-Title" value="Example"/> |
| 146 |
<attribute name="Specification-Version" value="${version}"/> |
| 147 |
<attribute name="Specification-Vendor" value="Example Organization"/> |
| 148 |
<attribute name="Implementation-Title" value="common"/> |
| 149 |
<attribute name="Implementation-Version" value="${version} ${TODAY}"/> |
| 150 |
<attribute name="Implementation-Vendor" value="Example Corp."/> |
| 151 |
</section> |
| 152 |
<section name="common/class1.class"> |
| 153 |
<attribute name="Sealed" value="false"/> |
| 154 |
</section> |
| 155 |
</manifest></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> |