public class Link extends Task
jlink command.
Supported attributes:
destDir
modulePath
modulePathRef
modules
<module> elements are present.
observableModules
launchers
=module or
name=module/mainclass
excludeFiles
@filename.
excludeResources
@filename.
locales
jdk.localedata module
resourceOrder
@filename.
bindServices
ignoreSigning
includeHeaders
includeManPages
includeNativeCommands
debug
verboseLevel
DEBUG, VERBOSE,
INFO}, WARN, or ERR).
compress
0
none
1
strings
2
zip
endianness
little or big, default is native endianness
checkDuplicateLegal
vmType
client
server
minimal
all (default)
Supported nested elements
<modulepath>
<module>
name attribute.
<observableModule>
name attribute.
<launcher>
name (required)
module (required)
mainClass (optional)
<locale>
name attribute.
<resourceOrder>
pattern
listFile
resourceOrder attribute is also present on the task, its
patterns are treated as if they occur before patterns in nested
<resourceOrder> elements.
<excludeFiles>
pattern
listFile
<excludeResources>
pattern
listFile
<compress>
level attribute, whose permitted values are the same
as the compress task attribute described above.
May also have a files attribute, which is a comma-separated
list of patterns, and/or nested <files> elements, each with
either a pattern attribute or listFile attribute.
<releaseInfo>
file attribute, pointing to a Java properties file
containing new release info properties that will entirely replace
the current ones.
delete attribute, containing comma-separated property keys
to remove from application's release info, and/or any number of
nested <delete> elements, each with a required key
attribute.
<add> elements, containing either
key and value attributes, or a file
attribute and an optional charset attribute.
jlink tool reference| Modifier and Type | Class and Description |
|---|---|
class |
Link.Compression
Child element fully describing compression of a linked image.
|
static class |
Link.CompressionLevel
Possible attribute values for compression level of a linked image:
0
none
no compression (default)
1
strings
constant string sharing
2
zip
zip compression
|
static class |
Link.Endianness
Possible values for linked image endianness:
little and big. |
class |
Link.Launcher
Child element representing a custom launcher command in a linked image.
|
class |
Link.LocaleSpec
Child element that contains a pattern matching Java locales.
|
class |
Link.ModuleSpec
Child element that explicitly names a Java module.
|
class |
Link.PatternListEntry
Child element type which specifies a jlink files pattern.
|
class |
Link.ReleaseInfo
Child element describing changes to the default release properties
of a linked image.
|
class |
Link.ReleaseInfoEntry
Grandchild element describing additional release info properties for a
linked image.
|
class |
Link.ReleaseInfoKey
Grandchild element representing deletable key in a linked image's
release properties.
|
static class |
Link.VMType
Possible values for JVM type in linked image:
client, server, minimal, or all. |
description, location, project| Constructor and Description |
|---|
Link() |
| Modifier and Type | Method and Description |
|---|---|
Link.Compression |
createCompress()
Creates child
<compress> element that specifies the level of
compression the linker will apply, and optionally, which files in the
image will be compressed. |
Link.PatternListEntry |
createExcludeFiles()
Creates child
<excludeFiles> element that specifies
files to exclude from linked modules when assembling linked image. |
Link.PatternListEntry |
createExcludeResources()
Creates child
<excludeResources> element that specifies
resources in linked modules that will be excluded from linked image. |
Link.Launcher |
createLauncher()
Creates child
<launcher> element that can contain information
on additional executable in the linked image. |
Link.LocaleSpec |
createLocale()
Creates child
<locale> element that specifies a Java locale,
or set of locales, to include from the jdk.localedata module
in the linked image. |
Link.ModuleSpec |
createModule()
Adds child
<module> element, specifying a module to link. |
Path |
createModulePath()
Adds child
<modulePath> element. |
Link.ModuleSpec |
createObservableModule()
Creates child
<observableModule> element that represents
one of the modules the linker is permitted to know about. |
Link.ReleaseInfo |
createReleaseInfo()
Creates child
<releaseInfo> element that modifies the default
release properties of the linked image. |
Link.PatternListEntry |
createResourceOrder()
Creates child
<resourceOrder element that specifies
explicit ordering of resources in linked image. |
void |
execute()
Invokes the jlink tool to create a new linked image, unless the
output directory exists and all of its files are files are newer
than all files in the module path.
|
boolean |
getBindServices()
Attribute indicating whether linked image should pull in providers
in the module path of services used by explicitly linked modules.
|
boolean |
getCheckDuplicateLegal()
Attribute indicating whether linker should check legal notices with
duplicate names, and refuse to merge them (usually using symbolic links)
if their respective content is not identical.
|
Link.CompressionLevel |
getCompress()
Attribute indicating level of compression linker will apply to image.
|
boolean |
getDebug()
Attribute indicating whether linker should keep or strip
debug information in classes.
|
java.io.File |
getDestDir()
Required attribute containing directory where linked image will be
created.
|
Link.Endianness |
getEndianness()
Attribute which indicates whether certain files in the linked image
will be big-endian or little-endian.
|
boolean |
getIgnoreSigning()
Attribute indicating whether linker should allow modules made from
signed jars.
|
boolean |
getIncludeHeaders()
Attribute indicating whether to include header files from linked modules
in image.
|
boolean |
getIncludeManPages()
Attribute indicating whether to include man pages from linked modules
in image.
|
boolean |
getIncludeNativeCommands()
Attribute indicating whether to include generated native commands,
and native commands from linked modules, in image.
|
Path |
getModulePath()
Attribute containing path of directories containing linkable modules.
|
LogLevel |
getVerboseLevel()
Attribute indicating whether linker should produce verbose output,
and at what logging level that output should be shown.
|
Link.VMType |
getVmType()
Attribute indicating what type of JVM the linked image should have.
|
void |
setBindServices(boolean bind)
Sets attribute indicating whether linked image should pull in providers
in the module path of services used by explicitly linked modules.
|
void |
setCheckDuplicateLegal(boolean check)
Sets attribute indicating whether linker should check legal notices with
duplicate names, and refuse to merge them (usually using symbolic links)
if their respective content is not identical.
|
void |
setCompress(Link.CompressionLevel level)
Sets attribute indicating level of compression linker will apply
to image.
|
void |
setDebug(boolean debug)
Sets attribute indicating whether linker should keep or strip
debug information in classes.
|
void |
setDestDir(java.io.File dir)
Sets attribute indicating directory where linked image will be created.
|
void |
setEndianness(Link.Endianness endianness)
Sets attribute which indicates whether certain files in the linked image
will be big-endian or little-endian.
|
void |
setExcludeFiles(java.lang.String patternList)
Sets attribute containing a list of patterns denoting files
to exclude from linked modules when assembling linked image.
|
void |
setExcludeResources(java.lang.String patternList)
Sets attribute containing a list of patterns denoting resources
to exclude from linked modules in linked image.
|
void |
setIgnoreSigning(boolean ignore)
Sets attribute indicating whether linker should allow modules made from
signed jars.
|
void |
setIncludeHeaders(boolean include)
Sets attribute indicating whether to include header files from
linked modules in image.
|
void |
setIncludeManPages(boolean include)
Sets attribute indicating whether to include man pages from
linked modules in image.
|
void |
setIncludeNativeCommands(boolean include)
Sets attribute indicating whether to include generated native commands,
and native commands from linked modules, in image.
|
void |
setLaunchers(java.lang.String launcherList)
Sets attribute containing comma-separated list of information needed for
additional executables in the linked image.
|
void |
setLocales(java.lang.String localeList)
Sets attribute containing a list of locale patterns, to specify
Java locales to include from
jdk.localedata module in
linked image. |
void |
setModulePath(Path path)
Sets attribute containing path of directories containing
linkable modules.
|
void |
setModulePathRef(Reference ref)
Sets module path as a reference.
|
void |
setModules(java.lang.String moduleList)
Sets attribute containing list of modules to link.
|
void |
setObservableModules(java.lang.String moduleList)
Sets attribute containing modules linker is permitted to know about.
|
void |
setResourceOrder(java.lang.String patternList)
Sets attribute containing a list of patterns that explicitly
order resources in the linked image.
|
void |
setVerboseLevel(LogLevel level)
Sets attribute indicating whether linker should produce verbose output,
and at what logging level that output should be shown.
|
void |
setVmType(Link.VMType type)
Set attribute indicating what type of JVM the linked image should have.
|
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskTypeclone, getDescription, getLocation, getProject, setDescription, setLocation, setProjectpublic Path createModulePath()
<modulePath> element.setModulePath(Path)public Path getModulePath()
nullsetModulePath(Path),
createModulePath()public void setModulePath(Path path)
path - new module pathgetModulePath(),
setModulePathRef(Reference),
createModulePath()public void setModulePathRef(Reference ref)
ref - path referencesetModulePath(Path),
createModulePath()public Link.ModuleSpec createModule()
<module> element, specifying a module to link.setModules(String)public void setModules(java.lang.String moduleList)
moduleList - comma-separated list of module namespublic Link.ModuleSpec createObservableModule()
<observableModule> element that represents
one of the modules the linker is permitted to know about.public void setObservableModules(java.lang.String moduleList)
moduleList - comma-separated list of module namespublic Link.Launcher createLauncher()
<launcher> element that can contain information
on additional executable in the linked image.setLaunchers(String)public void setLaunchers(java.lang.String launcherList)
=module or
name=module/mainclass.launcherList - comma-separated list of launcher datapublic Link.LocaleSpec createLocale()
<locale> element that specifies a Java locale,
or set of locales, to include from the jdk.localedata module
in the linked image.public void setLocales(java.lang.String localeList)
jdk.localedata module in
linked image. Asterisks (*) are permitted for wildcard
matches.localeList - comma-separated list of locale patternspublic Link.PatternListEntry createExcludeFiles()
<excludeFiles> element that specifies
files to exclude from linked modules when assembling linked image.setExcludeFiles(String)public void setExcludeFiles(java.lang.String patternList)
patternList - comman-separated list of patternsLink.PatternListEntrypublic Link.PatternListEntry createExcludeResources()
<excludeResources> element that specifies
resources in linked modules that will be excluded from linked image.setExcludeResources(String)public void setExcludeResources(java.lang.String patternList)
patternList - comma-separated list of patternscreateExcludeResources(),
Link.PatternListEntrypublic Link.PatternListEntry createResourceOrder()
<resourceOrder element that specifies
explicit ordering of resources in linked image.setResourceOrder(String)public void setResourceOrder(java.lang.String patternList)
patternList - comma-separated list of patternscreateResourceOrder(),
Link.PatternListEntrypublic boolean getBindServices()
setBindServices(boolean)public void setBindServices(boolean bind)
bind - whether to include service providersgetBindServices()public boolean getIgnoreSigning()
setIgnoreSigning(boolean)public void setIgnoreSigning(boolean ignore)
Note: As of Java 11, this attribute is internally forced to true. See the source.
ignore - true to have linker allow signed jars,
false to have linker emit an error for signed jarsgetIgnoreSigning()public boolean getIncludeHeaders()
setIncludeHeaders(boolean)public void setIncludeHeaders(boolean include)
include - true if header files should be included,
false to exclude themgetIncludeHeaders()public boolean getIncludeManPages()
setIncludeManPages(boolean)public void setIncludeManPages(boolean include)
include - true if man pages should be included,
false to exclude themgetIncludeManPages()public boolean getIncludeNativeCommands()
setIncludeNativeCommands(boolean)public void setIncludeNativeCommands(boolean include)
include - true if native commands should be included,
false to exclude themgetIncludeNativeCommands()public boolean getDebug()
setDebug(boolean)public void setDebug(boolean debug)
debug - true if debug information should be retained,
false if it should be strippedgetDebug()public LogLevel getVerboseLevel()
null to disable verbose outputsetVerboseLevel(LogLevel)public void setVerboseLevel(LogLevel level)
level - level logging level at which to show linker's
verbose output, or null to disable verbose outputgetVerboseLevel()public java.io.File getDestDir()
setDestDir(File)public void setDestDir(java.io.File dir)
dir - directory in which image will be created by linkergetDestDir()public Link.CompressionLevel getCompress()
createCompress(): only one
of the two may be specified.null for nonesetCompress(Link.CompressionLevel),
createCompress()public void setCompress(Link.CompressionLevel level)
createCompress():
only one of the two may be specified.level - compression level to apply, or null for nonegetCompress(),
createCompress()public Link.Compression createCompress()
<compress> element that specifies the level of
compression the linker will apply, and optionally, which files in the
image will be compressed. This is exclusive with regard to the
compress attribute: only one of the two may be
specified.setCompress(Link.CompressionLevel)public Link.Endianness getEndianness()
null, the underlying
platform's endianness is used.null to platform defaultsetEndianness(Link.Endianness)public void setEndianness(Link.Endianness endianness)
null, the underlying
platform's endianness is used.endianness - endianness to apply, or null to use
platform defaultgetEndianness()public boolean getCheckDuplicateLegal()
setCheckDuplicateLegal(boolean)public void setCheckDuplicateLegal(boolean check)
check - true if legal notice files with same name should be checked
for identical content, false to suppress checkgetCheckDuplicateLegal()public Link.VMType getVmType()
null, all JVM types are included.setVmType(Link.VMType)public void setVmType(Link.VMType type)
null, all JVM types are included.type - type of JVM linked image will havegetVmType()public Link.ReleaseInfo createReleaseInfo()
<releaseInfo> element that modifies the default
release properties of the linked image.public void execute()
throws BuildException
execute in class TaskBuildException - if destDir is not setBuildException - if module path is unset or emptyBuildException - if module list is emptyBuildException - if compressionLevel attribute and compression
child element are both specified