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

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