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.

jlink.html 6.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  18. <title>JLink Task</title>
  19. </head>
  20. <body>
  21. <h2><a name="jlink">Jlink</a></h2>
  22. <h3><i>Deprecated</i></h3>
  23. <p><i>This task has been deprecated. Use a <a href="../CoreTypes/zipfileset.html">zipfileset</a>
  24. or <a href="../CoreTasks/zip.html#zipgroupfileset">zipgroupfileset</a> with the
  25. <a href="../CoreTasks/jar.html">Jar task</a> or <a href="../CoreTasks/zip.html">Zip task</a>
  26. instead.</i></p>
  27. <h3><b>Description:</b></h3>
  28. <p>Links entries from sub-builds and libraries.</p>
  29. <p>The jlink task can be used to build jar and zip files, similar to
  30. the <i>jar</i> task.
  31. However, jlink provides options for controlling the way entries from
  32. input files
  33. are added to the output file. Specifically, capabilities for merging
  34. entries from
  35. multiple zip or jar files is available.</p>
  36. <p>If a mergefile is specified directly (eg. at the top level of a
  37. <i>mergefiles</i>
  38. pathelement) <i>and</i> the mergefile ends in &quot;.zip&quot; or
  39. &quot;.jar&quot;,
  40. entries in the mergefile will be merged into the outfile. A file with
  41. any other extension
  42. will be added to the output file, even if it is specified in the
  43. mergefiles element.
  44. Directories specified in either the mergefiles or addfiles element
  45. are added to the
  46. output file as you would expect: all files in subdirectories are
  47. recursively added to
  48. the output file with appropriate prefixes in the output file
  49. (without merging).
  50. </p>
  51. <p>
  52. In the case where duplicate entries and/or files are found among the
  53. files to be merged or
  54. added, jlink merges or adds the first entry and ignores all subsequent entries.
  55. </p>
  56. <p>
  57. jlink ignores META-INF directories in mergefiles. Users should supply their
  58. own manifest information for the output file.
  59. </p>
  60. <p>It is possible to refine the set of files that are being jlinked.
  61. This can be
  62. done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>,
  63. <i>excludesfile</i>,
  64. and <i>defaultexcludes</i> attributes on the <i>addfiles</i> and
  65. <i>mergefiles</i>
  66. nested elements. With the <i>includes</i> or <i>includesfile</i>
  67. attribute you specify the files you want to have included by using patterns.
  68. The <i>exclude</i> or <i>excludesfile</i> attribute is used to specify
  69. the files you want to have excluded. This is also done with patterns. And
  70. finally with the <i>defaultexcludes</i> attribute, you can specify whether you
  71. want to use default exclusions or not. See the section on <a
  72. href="../dirtasks.html#directorybasedtasks">directory based tasks</a>, on how the
  73. inclusion/exclusion of files works, and how to write patterns. The patterns are
  74. relative to the <i>base</i> directory.</p>
  75. <h3>Parameters:</h3>
  76. <table border="1" cellpadding="2" cellspacing="0">
  77. <tr>
  78. <td valign="top"><b>Attribute</b></td>
  79. <td valign="top"><b>Description</b></td>
  80. <td align="center" valign="top"><b>Required</b></td>
  81. </tr>
  82. <tr>
  83. <td valign="top">outfile</td>
  84. <td valign="top">the path of the output file.</td>
  85. <td valign="top" align="center">Yes</td>
  86. </tr>
  87. <tr>
  88. <td valign="top">compress</td>
  89. <td valign="top">whether or not the output should be compressed.
  90. <i>true</i>,
  91. <i>yes</i>, or <i>on</i> result in compressed output.
  92. If omitted, output will be uncompressed (inflated).</td>
  93. <td valign="top" align="center">No</td>
  94. </tr>
  95. <tr>
  96. <td valign="top">mergefiles</td>
  97. <td valign="top">files to be merged into the output, if possible.</td>
  98. <td valign="middle" align="center" rowspan="2">At least one of
  99. mergefiles or addfiles</td>
  100. </tr>
  101. <tr>
  102. <td valign="top">addfiles</td>
  103. <td valign="top">files to be added to the output.</td>
  104. </tr>
  105. </table>
  106. <h3>Examples</h3>
  107. <p>The following will merge the entries in mergefoo.jar and mergebar.jar
  108. into out.jar.
  109. mac.jar and pc.jar will be added as single entries to out.jar.</p>
  110. <pre>
  111. &lt;jlink compress=&quot;false&quot; outfile=&quot;out.jar&quot;&gt;
  112. &lt;mergefiles&gt;
  113. &lt;pathelement path=&quot;${build.dir}/mergefoo.jar&quot;/&gt;
  114. &lt;pathelement path=&quot;${build.dir}/mergebar.jar&quot;/&gt;
  115. &lt;/mergefiles&gt;
  116. &lt;addfiles&gt;
  117. &lt;pathelement path=&quot;${build.dir}/mac.jar&quot;/&gt;
  118. &lt;pathelement path=&quot;${build.dir}/pc.zip&quot;/&gt;
  119. &lt;/addfiles&gt;
  120. &lt;/jlink&gt;
  121. </pre>
  122. <p><b>Non-deprecated alternative to the above:</b></p>
  123. <pre>
  124. &lt;jar compress=&quot;false&quot; destfile=&quot;out.jar&quot;&gt;
  125. &lt;zipgroupfileset dir=&quot;${build.dir}&quot;&gt;
  126. &lt;include name=&quot;mergefoo.jar&quot;/&gt;
  127. &lt;include name=&quot;mergebar.jar&quot;/&gt;
  128. &lt;/zipgroupfileset&gt;
  129. &lt;fileset dir=&quot;${build.dir}&quot;&gt;
  130. &lt;include name=&quot;mac.jar&quot;/&gt;
  131. &lt;include name=&quot;pc.jar&quot;/&gt;
  132. &lt;/fileset&gt;
  133. &lt;/jar&gt;
  134. </pre>
  135. <p>Suppose the file foo.jar contains two entries: bar.class and
  136. barnone/myClass.zip.
  137. Suppose the path for file foo.jar is build/tempbuild/foo.jar. The
  138. following example
  139. will provide the entry tempbuild/foo.jar in the out.jar.</p>
  140. <pre>
  141. &lt;jlink compress=&quot;false&quot; outfile=&quot;out.jar&quot;&gt;
  142. &lt;mergefiles&gt;
  143. &lt;pathelement path=&quot;build/tempbuild&quot;/&gt;
  144. &lt;/mergefiles&gt;
  145. &lt;/jlink&gt;
  146. </pre>
  147. <p>However, the next example would result in two top-level entries in out.jar,
  148. namely bar.class and barnone/myClass.zip</p>
  149. <pre>
  150. &lt;jlink compress=&quot;false&quot; outfile=&quot;out.jar&quot;&gt;
  151. &lt;mergefiles&gt;
  152. &lt;pathelement path=&quot;build/tempbuild/foo.jar&quot;/&gt;
  153. &lt;/mergefiles&gt;
  154. &lt;/jlink&gt;
  155. </pre>
  156. </body>
  157. </html>