source: release-kits/lirk3/bin/ant-installer/web/manual/manual/OptionalTasks/jlink.html@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

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