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.

manifestclasspath.html 4.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. https://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <html lang="en">
  17. <head>
  18. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  19. <title>ManifestClassPath Task</title>
  20. </head>
  21. <body>
  22. <h2 id="manifestclasspath">Manifestclasspath</h2>
  23. <p><em>Since Apache Ant 1.7</em></p>
  24. <h3>Description</h3>
  25. <p>Converts a <a href="../using.html#path">Path</a> into a property whose value is appropriate for
  26. a <a href="manifest.html">Manifest</a>'s <code>Class-Path</code> attribute.</p>
  27. <p>This task is often used to work around command line limitations on Windows when using very long
  28. class paths when launching an application. The long class path normally specified on the command
  29. line is replaced by a single (possibly empty) jar file which an in-manifest <code>Class-Path</code>
  30. attribute whose value lists all the jar and zip files the classpath should contain. The files
  31. referenced from this attribute must be found relatively to the jar file itself, usually in the same
  32. directory. JVM automatically uses all file entries listed in the <code>Class-Path</code> attributes
  33. of a jar to locate/load classes. Note though that it silently ignores entries for which it cannot
  34. find any corresponding file.</p>
  35. <p>Note that the property value created may be longer than a manifest's maximum 72 characters per
  36. line, but will be properly wrapped as per the Jar specification by the <code>&lt;manifest&gt;</code>
  37. element, where the defined property is re-referenced.</p>
  38. <p>For this task to work properly the relative path from the file given in the <code>jarfile</code>
  39. attribute to the elements of the nested <code>classpath</code> must be the same as you expect them
  40. to be when deploying the jar.</p>
  41. <h3>Parameters</h3>
  42. <table class="attr">
  43. <tr>
  44. <th scope="col">Attribute</th>
  45. <th scope="col">Description</th>
  46. <th scope="col">Required</th>
  47. </tr>
  48. <tr>
  49. <td>property</td>
  50. <td>the name of the property to set. This property must not already be set.</td>
  51. <td>Yes</td>
  52. </tr>
  53. <tr>
  54. <td>jarfile</td>
  55. <td>the filename for the Jar which will contain the manifest that will use the property this
  56. task will set. This file need not exist yet, but its parent directory must exist.</td>
  57. <td>Yes</td>
  58. </tr>
  59. <tr>
  60. <td>maxParentLevels</td>
  61. <td>The maximum number of parent directories one is allowed to traverse to navigate from the jar
  62. file to the path entry. Put differently, the maximum number of <q>..</q> which is allowed in
  63. the relative path from the jar file to a given class path entry. Specify <q>0</q> to enforce a
  64. path entry to be in the same directory (or one of its sub-directories) as the jar file
  65. itself.</td>
  66. <td>No; defaults to <q>2</q></td>
  67. </tr>
  68. </table>
  69. <h3>Parameters specified as nested elements</h3>
  70. <h4>classpath</h4>
  71. <p>A <a href="../using.html#path">path-like</a> element, which can be defined in-place, or refer to
  72. a path defined elsewhere using the <code>&lt;classpath refid=&quot;pathid&quot;/&gt;</code> syntax.
  73. This classpath must not be empty, and is required.</p>
  74. <h3>Examples</h3>
  75. <p>Assuming a path with <var>id</var>=<q>classpath</q> was already defined, convert this path
  76. relatively to the <samp>build/</samp> directory that will contain <samp>acme.jar</samp>, which can
  77. later be created with <code>&lt;jar&gt;</code> with a nested <code>&lt;manifest&gt;</code> element
  78. that lists an <code>&lt;attribute name="Class-Path" value="${jar.classpath}"/&gt;</code>.</p>
  79. <pre>
  80. &lt;manifestclasspath property="jar.classpath"
  81. jarfile="build/acme.jar"&gt;
  82. &lt;classpath refid="classpath"/&gt;
  83. &lt;/manifestclasspath&gt;</pre>
  84. </body>
  85. </html>