Cari di Apache Ant 
    Apache Ant User Manual
Daftar Isi
(Sebelumnya) JJTreeJspC (Berikutnya)
Apache Ant Tasks

Jlink

Jlink

Deprecated

This task has been deprecated. Use a zipfileset or zipgroupfileset with the Jar task or Zip task instead.

Description:

Links entries from sub-builds and libraries.

The jlink task can be used to build jar and zip files, similar to the jar task.However, jlink provides options for controlling the way entries from input filesare added to the output file. Specifically, capabilities for merging entries frommultiple zip or jar files is available.

If a mergefile is specified directly (eg. at the top level of a mergefilespathelement) and the mergefile ends in ".zip" or ".jar",entries in the mergefile will be merged into the outfile. A file with any other extensionwill be added to the output file, even if it is specified in the mergefiles element.Directories specified in either the mergefiles or addfiles element are added to theoutput file as you would expect: all files in subdirectories are recursively added tothe output file with appropriate prefixes in the output file (without merging).

In the case where duplicate entries and/or files are found among the files to be merged oradded, jlink merges or adds the first entry and ignores all subsequent entries.

jlink ignores META-INF directories in mergefiles. Users should supply theirown manifest information for the output file.

It is possible to refine the set of files that are being jlinked. This can bedone with the includes, includesfile, excludes, excludesfile,and defaultexcludes attributes on the addfiles and mergefilesnested elements. With the includes or includesfileattribute you specify the files you want to have included by using patterns.The exclude or excludesfile attribute is used to specifythe files you want to have excluded. This is also done with patterns. Andfinally with the defaultexcludes attribute, you can specify whether youwant to use default exclusions or not. See the section on directory based tasks, on how theinclusion/exclusion of files works, and how to write patterns. The patterns arerelative to the base directory.

Parameters:

Attribute Description Required
outfile the path of the output file. Yes
compress whether or not the output should be compressed. true, yes, or on result in compressed output. If omitted, output will be uncompressed (inflated). No
mergefiles files to be merged into the output, if possible. At least one of mergefiles or addfiles
addfiles files to be added to the output.

Examples

The following will merge the entries in mergefoo.jar and mergebar.jar into out.jar.mac.jar and pc.jar will be added as single entries to out.jar.

<jlink compress="false" outfile="out.jar">   <mergefiles> <pathelement path="${build.dir}/mergefoo.jar"/> <pathelement path="${build.dir}/mergebar.jar"/>   </mergefiles>   <addfiles> <pathelement path="${build.dir}/mac.jar"/> <pathelement path="${build.dir}/pc.zip"/>   </addfiles></jlink>

Non-deprecated alternative to the above:

<jar compress="false" destfile="out.jar">  <zipgroupfileset dir="${build.dir}"> <include name="mergefoo.jar"/> <include name="mergebar.jar"/>  </zipgroupfileset>  <fileset dir="${build.dir}"> <include name="mac.jar"/> <include name="pc.jar"/>  </fileset></jar>

Suppose the file foo.jar contains two entries: bar.class and barnone/myClass.zip.Suppose the path for file foo.jar is build/tempbuild/foo.jar. The following examplewill provide the entry tempbuild/foo.jar in the out.jar.

<jlink compress="false" outfile="out.jar">   <mergefiles> <pathelement path="build/tempbuild"/>   </mergefiles></jlink>

However, the next example would result in two top-level entries in out.jar,namely bar.class and barnone/myClass.zip

<jlink compress="false" outfile="out.jar">   <mergefiles> <pathelement path="build/tempbuild/foo.jar"/>   </mergefiles></jlink>
(Sebelumnya) JJTreeJspC (Berikutnya)