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

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