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