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

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