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 5.5 KiB

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