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.2 KiB

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