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
|
---|
32 | the <i>jar</i> task.
|
---|
33 | However, jlink provides options for controlling the way entries from
|
---|
34 | input files
|
---|
35 | are added to the output file. Specifically, capabilities for merging
|
---|
36 | entries from
|
---|
37 | multiple 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>
|
---|
41 | pathelement) <i>and</i> the mergefile ends in ".zip" or
|
---|
42 | ".jar",
|
---|
43 | entries in the mergefile will be merged into the outfile. A file with
|
---|
44 | any other extension
|
---|
45 | will be added to the output file, even if it is specified in the
|
---|
46 | mergefiles element.
|
---|
47 | Directories specified in either the mergefiles or addfiles element
|
---|
48 | are added to the
|
---|
49 | output file as you would expect: all files in subdirectories are
|
---|
50 | recursively added to
|
---|
51 | the output file with appropriate prefixes in the output file
|
---|
52 | (without merging).
|
---|
53 | </p>
|
---|
54 |
|
---|
55 | <p>
|
---|
56 | In the case where duplicate entries and/or files are found among the
|
---|
57 | files to be merged or
|
---|
58 | added, jlink merges or adds the first entry and ignores all subsequent entries.
|
---|
59 | </p>
|
---|
60 |
|
---|
61 | <p>
|
---|
62 | jlink ignores META-INF directories in mergefiles. Users should supply their
|
---|
63 | own manifest information for the output file.
|
---|
64 | </p>
|
---|
65 |
|
---|
66 | <p>It is possible to refine the set of files that are being jlinked.
|
---|
67 | This can be
|
---|
68 | done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>,
|
---|
69 | <i>excludesfile</i>,
|
---|
70 | and <i>defaultexcludes</i> attributes on the <i>addfiles</i> and
|
---|
71 | <i>mergefiles</i>
|
---|
72 | nested elements. With the <i>includes</i> or <i>includesfile</i>
|
---|
73 | attribute you specify the files you want to have included by using patterns.
|
---|
74 | The <i>exclude</i> or <i>excludesfile</i> attribute is used to specify
|
---|
75 | the files you want to have excluded. This is also done with patterns. And
|
---|
76 | finally with the <i>defaultexcludes</i> attribute, you can specify whether you
|
---|
77 | want to use default exclusions or not. See the section on <a
|
---|
78 | href="../dirtasks.html#directorybasedtasks">directory based tasks</a>, on how the
|
---|
79 | inclusion/exclusion of files works, and how to write patterns. The patterns are
|
---|
80 | relative 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
|
---|
108 | mergefiles 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
|
---|
119 | into out.jar.
|
---|
120 | mac.jar and pc.jar will be added as single entries to out.jar.</p>
|
---|
121 | <pre>
|
---|
122 | <jlink compress="false" outfile="out.jar">
|
---|
123 | <mergefiles>
|
---|
124 | <pathelement path="${build.dir}/mergefoo.jar"/>
|
---|
125 | <pathelement path="${build.dir}/mergebar.jar"/>
|
---|
126 | </mergefiles>
|
---|
127 | <addfiles>
|
---|
128 | <pathelement path="${build.dir}/mac.jar"/>
|
---|
129 | <pathelement path="${build.dir}/pc.zip"/>
|
---|
130 | </addfiles>
|
---|
131 | </jlink>
|
---|
132 | </pre>
|
---|
133 |
|
---|
134 | <p><b>Non-deprecated alternative to the above:</b></p>
|
---|
135 | <pre>
|
---|
136 | <jar compress="false" destfile="out.jar">
|
---|
137 | <zipgroupfileset dir="${build.dir}">
|
---|
138 | <include name="mergefoo.jar"/>
|
---|
139 | <include name="mergebar.jar"/>
|
---|
140 | </zipgroupfileset>
|
---|
141 | <fileset dir="${build.dir}">
|
---|
142 | <include name="mac.jar"/>
|
---|
143 | <include name="pc.jar"/>
|
---|
144 | </fileset>
|
---|
145 | </jar>
|
---|
146 | </pre>
|
---|
147 |
|
---|
148 | <p>Suppose the file foo.jar contains two entries: bar.class and
|
---|
149 | barnone/myClass.zip.
|
---|
150 | Suppose the path for file foo.jar is build/tempbuild/foo.jar. The
|
---|
151 | following example
|
---|
152 | will provide the entry tempbuild/foo.jar in the out.jar.</p>
|
---|
153 | <pre>
|
---|
154 | <jlink compress="false" outfile="out.jar">
|
---|
155 | <mergefiles>
|
---|
156 | <pathelement path="build/tempbuild"/>
|
---|
157 | </mergefiles>
|
---|
158 | </jlink>
|
---|
159 | </pre>
|
---|
160 |
|
---|
161 | <p>However, the next example would result in two top-level entries in out.jar,
|
---|
162 | namely bar.class and barnone/myClass.zip</p>
|
---|
163 | <pre>
|
---|
164 | <jlink compress="false" outfile="out.jar">
|
---|
165 | <mergefiles>
|
---|
166 | <pathelement path="build/tempbuild/foo.jar"/>
|
---|
167 | </mergefiles>
|
---|
168 | </jlink>
|
---|
169 | </pre>
|
---|
170 |
|
---|
171 |
|
---|
172 | </body>
|
---|
173 |
|
---|
174 | </html>
|
---|