Class Link
- java.lang.Object
- 
- org.apache.tools.ant.ProjectComponent
- 
- org.apache.tools.ant.Task
- 
- org.apache.tools.ant.taskdefs.modules.Link
 
 
 
- 
- All Implemented Interfaces:
- java.lang.Cloneable
 
 public class Link extends Task Assembles jmod files into an executable image. Equivalent to the JDKjlinkcommand.Supported attributes: - destDir
- Root directory of created image. (required)
- modulePath
- Path of modules. Should be a list of .jmod files. Required, unless nested module path or modulepathref is present.
- modulePathRef
- Reference to path of modules. Referenced path should be a list of .jmod files.
- modules
- Comma-separated list of modules to assemble.  Required, unless
     one or more nested <module>elements are present.
- observableModules
- Comma-separated list of explicit modules that comprise "universe" visible to tool while linking.
- launchers
- Comma-separated list of commands, each of the form
     name=module or name=module/mainclass
- excludeFiles
- Comma-separated list of patterns specifying files to exclude from
     linked image.
     Each is either a standard PathMatcher pattern
     or @filename.
- excludeResources
- Comma-separated list of patterns specifying resources to exclude from jmods.
     Each is either a standard PathMatcher pattern
     or @filename.
- locales
- Comma-separated list of extra locales to include,
     requires jdk.localedatamodule
- resourceOrder
- Comma-separated list of patterns specifying resource search order. Each is either a standard PathMatcher pattern or
- @filename.- bindServices
- Comma-separated list of patterns specifying resource search order. Each is either a standard PathMatcher pattern or
- boolean, whether to link service providers; default is false
- ignoreSigning
- boolean, whether to allow signed jar files; default is false
- includeHeaders
- boolean, whether to include header files; default is true
- includeManPages
- boolean, whether to include man pages; default is true
- includeNativeCommands
- boolean, whether to include native executables normally generated for image; default is true
- debug
- boolean, whether to include debug information; default is true
- verboseLevel
- If set, jlink will produce verbose output, which will be logged at
     the specified Ant log level (DEBUG,VERBOSE,INFO},WARN, orERR).
- compress
- compression level, one of:
     - 0- none
- no compression (default)
- 1- strings
- constant string sharing
- 2- zip
- zip compression
 
- endianness
- Must be littleorbig, default is native endianness
- checkDuplicateLegal
- Boolean. When merging legal notices from different modules because they have the same name, verify that their contents are identical. Default is false, which means any license files with the same name are assumed to have the same content, and no checking is done.
- vmType
- Hotspot VM in image, one of:
     - client
- server
- minimal
- all(default)
 
 Supported nested elements - <modulepath>
- path element
- <module>
- May be specified multiple times.
     Only attribute is required nameattribute.
- <observableModule>
- May be specified multiple times.
     Only attribute is required nameattribute.
- <launcher>
- May be specified multiple times.  Attributes:
     - name(required)
- module(required)
- mainClass(optional)
 
- <locale>
- May be specified multiple times.
     Only attribute is required nameattribute.
- <resourceOrder>
- Explicit resource search order in image.  May be specified multiple
     times.  Exactly one of these attributes must be specified:
     - pattern
- A standard PathMatcher pattern
- listFile
- Text file containing list of resource names (not patterns), one per line
 resourceOrderattribute is also present on the task, its patterns are treated as if they occur before patterns in nested<resourceOrder>elements.
- <excludeFiles>
- Excludes files from linked image tree.  May be specified multiple times.
     Exactly one of these attributes is required:
     - pattern
- A standard PathMatcher pattern
- listFile
- Text file containing list of file names (not patterns), one per line
 
- <excludeResources>
- Excludes resources from jmods.  May be specified multiple times.
     Exactly one of these attributes is required:
     - pattern
- A standard PathMatcher pattern
- listFile
- Text file containing list of resource names (not patterns), one per line
 
- <compress>
- Must have levelattribute, whose permitted values are the same as thecompresstask attribute described above. May also have afilesattribute, which is a comma-separated list of patterns, and/or nested<files>elements, each with either apatternattribute orlistFileattribute.
- <releaseInfo>
- Replaces, augments, or trims the image's release info properties.
     This may specify any of the following:
     - A fileattribute, pointing to a Java properties file containing new release info properties that will entirely replace the current ones.
- A deleteattribute, containing comma-separated property keys to remove from application's release info, and/or any number of nested<delete>elements, each with a requiredkeyattribute.
- One or more nested <add>elements, containing eitherkeyandvalueattributes, or afileattribute and an optionalcharsetattribute.
 
- A 
 - Since:
- 1.10.6
- See Also:
- jlinktool reference
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description classLink.CompressionChild element fully describing compression of a linked image.static classLink.CompressionLevelPossible attribute values for compression level of a linked image:0noneno compression (default)1stringsconstant string sharing2zipzip compressionstatic classLink.EndiannessPossible values for linked image endianness:littleandbig.classLink.LauncherChild element representing a custom launcher command in a linked image.classLink.LocaleSpecChild element that contains a pattern matching Java locales.classLink.ModuleSpecChild element that explicitly names a Java module.classLink.PatternListEntryChild element type which specifies a jlink files pattern.classLink.ReleaseInfoChild element describing changes to the default release properties of a linked image.classLink.ReleaseInfoEntryGrandchild element describing additional release info properties for a linked image.classLink.ReleaseInfoKeyGrandchild element representing deletable key in a linked image's release properties.static classLink.VMTypePossible values for JVM type in linked image:client,server,minimal, orall.
 - 
Field Summary- 
Fields inherited from class org.apache.tools.ant.ProjectComponentdescription, location, project
 
- 
 - 
Constructor SummaryConstructors Constructor Description Link()
 - 
Method SummaryModifier and Type Method Description Link.CompressioncreateCompress()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.PatternListEntrycreateExcludeFiles()Creates child<excludeFiles>element that specifies files to exclude from linked modules when assembling linked image.Link.PatternListEntrycreateExcludeResources()Creates child<excludeResources>element that specifies resources in linked modules that will be excluded from linked image.Link.LaunchercreateLauncher()Creates child<launcher>element that can contain information on additional executable in the linked image.Link.LocaleSpeccreateLocale()Creates child<locale>element that specifies a Java locale, or set of locales, to include from thejdk.localedatamodule in the linked image.Link.ModuleSpeccreateModule()Adds child<module>element, specifying a module to link.PathcreateModulePath()Adds child<modulePath>element.Link.ModuleSpeccreateObservableModule()Creates child<observableModule>element that represents one of the modules the linker is permitted to know about.Link.ReleaseInfocreateReleaseInfo()Creates child<releaseInfo>element that modifies the default release properties of the linked image.Link.PatternListEntrycreateResourceOrder()Creates child<resourceOrderelement that specifies explicit ordering of resources in linked image.voidexecute()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.booleangetBindServices()Attribute indicating whether linked image should pull in providers in the module path of services used by explicitly linked modules.booleangetCheckDuplicateLegal()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.CompressionLevelgetCompress()Attribute indicating level of compression linker will apply to image.booleangetDebug()Attribute indicating whether linker should keep or strip debug information in classes.java.io.FilegetDestDir()Required attribute containing directory where linked image will be created.Link.EndiannessgetEndianness()Attribute which indicates whether certain files in the linked image will be big-endian or little-endian.booleangetIgnoreSigning()Attribute indicating whether linker should allow modules made from signed jars.booleangetIncludeHeaders()Attribute indicating whether to include header files from linked modules in image.booleangetIncludeManPages()Attribute indicating whether to include man pages from linked modules in image.booleangetIncludeNativeCommands()Attribute indicating whether to include generated native commands, and native commands from linked modules, in image.PathgetModulePath()Attribute containing path of directories containing linkable modules.LogLevelgetVerboseLevel()Attribute indicating whether linker should produce verbose output, and at what logging level that output should be shown.Link.VMTypegetVmType()Attribute indicating what type of JVM the linked image should have.voidsetBindServices(boolean bind)Sets attribute indicating whether linked image should pull in providers in the module path of services used by explicitly linked modules.voidsetCheckDuplicateLegal(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.voidsetCompress(Link.CompressionLevel level)Sets attribute indicating level of compression linker will apply to image.voidsetDebug(boolean debug)Sets attribute indicating whether linker should keep or strip debug information in classes.voidsetDestDir(java.io.File dir)Sets attribute indicating directory where linked image will be created.voidsetEndianness(Link.Endianness endianness)Sets attribute which indicates whether certain files in the linked image will be big-endian or little-endian.voidsetExcludeFiles(java.lang.String patternList)Sets attribute containing a list of patterns denoting files to exclude from linked modules when assembling linked image.voidsetExcludeResources(java.lang.String patternList)Sets attribute containing a list of patterns denoting resources to exclude from linked modules in linked image.voidsetIgnoreSigning(boolean ignore)Sets attribute indicating whether linker should allow modules made from signed jars.voidsetIncludeHeaders(boolean include)Sets attribute indicating whether to include header files from linked modules in image.voidsetIncludeManPages(boolean include)Sets attribute indicating whether to include man pages from linked modules in image.voidsetIncludeNativeCommands(boolean include)Sets attribute indicating whether to include generated native commands, and native commands from linked modules, in image.voidsetLaunchers(java.lang.String launcherList)Sets attribute containing comma-separated list of information needed for additional executables in the linked image.voidsetLocales(java.lang.String localeList)Sets attribute containing a list of locale patterns, to specify Java locales to include fromjdk.localedatamodule in linked image.voidsetModulePath(Path path)Sets attribute containing path of directories containing linkable modules.voidsetModulePathRef(Reference ref)Sets module path as a reference.voidsetModules(java.lang.String moduleList)Sets attribute containing list of modules to link.voidsetObservableModules(java.lang.String moduleList)Sets attribute containing modules linker is permitted to know about.voidsetResourceOrder(java.lang.String patternList)Sets attribute containing a list of patterns that explicitly order resources in the linked image.voidsetVerboseLevel(LogLevel level)Sets attribute indicating whether linker should produce verbose output, and at what logging level that output should be shown.voidsetVmType(Link.VMType type)Set attribute indicating what type of JVM the linked image should have.- 
Methods inherited from class org.apache.tools.ant.TaskbindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 - 
Methods inherited from class org.apache.tools.ant.ProjectComponentclone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
- 
 
- 
- 
- 
Method Detail- 
createModulePathpublic Path createModulePath() Adds child<modulePath>element.- Returns:
- new, empty child element
- See Also:
- setModulePath(Path)
 
 - 
getModulePathpublic Path getModulePath() Attribute containing path of directories containing linkable modules.- Returns:
- current module path, possibly null
- See Also:
- setModulePath(Path),- createModulePath()
 
 - 
setModulePathpublic void setModulePath(Path path) Sets attribute containing path of directories containing linkable modules.- Parameters:
- path- new module path
- See Also:
- getModulePath(),- setModulePathRef(Reference),- createModulePath()
 
 - 
setModulePathRefpublic void setModulePathRef(Reference ref) Sets module path as a reference.- Parameters:
- ref- path reference
- See Also:
- setModulePath(Path),- createModulePath()
 
 - 
createModulepublic Link.ModuleSpec createModule() Adds child<module>element, specifying a module to link.- Returns:
- new, unconfigured child element
- See Also:
- setModules(String)
 
 - 
setModulespublic void setModules(java.lang.String moduleList) Sets attribute containing list of modules to link.- Parameters:
- moduleList- comma-separated list of module names
 
 - 
createObservableModulepublic Link.ModuleSpec createObservableModule() Creates child<observableModule>element that represents one of the modules the linker is permitted to know about.- Returns:
- new, unconfigured child element
 
 - 
setObservableModulespublic void setObservableModules(java.lang.String moduleList) Sets attribute containing modules linker is permitted to know about.- Parameters:
- moduleList- comma-separated list of module names
 
 - 
createLauncherpublic Link.Launcher createLauncher() Creates child<launcher>element that can contain information on additional executable in the linked image.- Returns:
- new, unconfigured child element
- See Also:
- setLaunchers(String)
 
 - 
setLauncherspublic void setLaunchers(java.lang.String launcherList) Sets attribute containing comma-separated list of information needed for additional executables in the linked image. Each item must be of the form * name=module or name=module/mainclass.- Parameters:
- launcherList- comma-separated list of launcher data
 
 - 
createLocalepublic Link.LocaleSpec createLocale() Creates child<locale>element that specifies a Java locale, or set of locales, to include from thejdk.localedatamodule in the linked image.- Returns:
- new, unconfigured child element
 
 - 
setLocalespublic void setLocales(java.lang.String localeList) Sets attribute containing a list of locale patterns, to specify Java locales to include fromjdk.localedatamodule in linked image. Asterisks (*) are permitted for wildcard matches.- Parameters:
- localeList- comma-separated list of locale patterns
 
 - 
createExcludeFilespublic Link.PatternListEntry createExcludeFiles() Creates child<excludeFiles>element that specifies files to exclude from linked modules when assembling linked image.- Returns:
- new, unconfigured child element
- See Also:
- setExcludeFiles(String)
 
 - 
setExcludeFilespublic void setExcludeFiles(java.lang.String patternList) Sets attribute containing a list of patterns denoting files to exclude from linked modules when assembling linked image.- Parameters:
- patternList- comman-separated list of patterns
- See Also:
- Link.PatternListEntry
 
 - 
createExcludeResourcespublic Link.PatternListEntry createExcludeResources() Creates child<excludeResources>element that specifies resources in linked modules that will be excluded from linked image.- Returns:
- new, unconfigured child element
- See Also:
- setExcludeResources(String)
 
 - 
setExcludeResourcespublic void setExcludeResources(java.lang.String patternList) Sets attribute containing a list of patterns denoting resources to exclude from linked modules in linked image.- Parameters:
- patternList- comma-separated list of patterns
- See Also:
- createExcludeResources(),- Link.PatternListEntry
 
 - 
createResourceOrderpublic Link.PatternListEntry createResourceOrder() Creates child<resourceOrderelement that specifies explicit ordering of resources in linked image.- Returns:
- new, unconfigured child element
- See Also:
- setResourceOrder(String)
 
 - 
setResourceOrderpublic void setResourceOrder(java.lang.String patternList) Sets attribute containing a list of patterns that explicitly order resources in the linked image. Any patterns specified here will be placed before any patterns specified as child elements.- Parameters:
- patternList- comma-separated list of patterns
- See Also:
- createResourceOrder(),- Link.PatternListEntry
 
 - 
getBindServicespublic boolean getBindServices() Attribute indicating whether linked image should pull in providers in the module path of services used by explicitly linked modules.- Returns:
- true if linked will pull in service provides, false if not
- See Also:
- setBindServices(boolean)
 
 - 
setBindServicespublic 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.- Parameters:
- bind- whether to include service providers
- See Also:
- getBindServices()
 
 - 
getIgnoreSigningpublic boolean getIgnoreSigning() Attribute indicating whether linker should allow modules made from signed jars.- Returns:
- true if signed jars are allowed, false if modules based on signed jars cause an error
- See Also:
- setIgnoreSigning(boolean)
 
 - 
setIgnoreSigningpublic void setIgnoreSigning(boolean ignore) Sets attribute indicating whether linker should allow modules made from signed jars.Note: As of Java 11, this attribute is internally forced to true. See the source. - Parameters:
- ignore- true to have linker allow signed jars, false to have linker emit an error for signed jars
- See Also:
- getIgnoreSigning()
 
 - 
getIncludeHeaderspublic boolean getIncludeHeaders() Attribute indicating whether to include header files from linked modules in image.- Returns:
- true if header files should be included, false to exclude them
- See Also:
- setIncludeHeaders(boolean)
 
 - 
setIncludeHeaderspublic void setIncludeHeaders(boolean include) Sets attribute indicating whether to include header files from linked modules in image.- Parameters:
- include- true if header files should be included, false to exclude them
- See Also:
- getIncludeHeaders()
 
 - 
getIncludeManPagespublic boolean getIncludeManPages() Attribute indicating whether to include man pages from linked modules in image.- Returns:
- true if man pages should be included, false to exclude them
- See Also:
- setIncludeManPages(boolean)
 
 - 
setIncludeManPagespublic void setIncludeManPages(boolean include) Sets attribute indicating whether to include man pages from linked modules in image.- Parameters:
- include- true if man pages should be included, false to exclude them
- See Also:
- getIncludeManPages()
 
 - 
getIncludeNativeCommandspublic boolean getIncludeNativeCommands() Attribute indicating whether to include generated native commands, and native commands from linked modules, in image.- Returns:
- true if native commands should be included, false to exclude them
- See Also:
- setIncludeNativeCommands(boolean)
 
 - 
setIncludeNativeCommandspublic void setIncludeNativeCommands(boolean include) Sets attribute indicating whether to include generated native commands, and native commands from linked modules, in image.- Parameters:
- include- true if native commands should be included, false to exclude them
- See Also:
- getIncludeNativeCommands()
 
 - 
getDebugpublic boolean getDebug() Attribute indicating whether linker should keep or strip debug information in classes.- Returns:
- true if debug information will be retained, false if it will be stripped
- See Also:
- setDebug(boolean)
 
 - 
setDebugpublic void setDebug(boolean debug) Sets attribute indicating whether linker should keep or strip debug information in classes.- Parameters:
- debug- true if debug information should be retained, false if it should be stripped
- See Also:
- getDebug()
 
 - 
getVerboseLevelpublic LogLevel getVerboseLevel() Attribute indicating whether linker should produce verbose output, and at what logging level that output should be shown.- Returns:
- logging level at which to show linker's verbose output,
         or nullto disable verbose output
- See Also:
- setVerboseLevel(LogLevel)
 
 - 
setVerboseLevelpublic void setVerboseLevel(LogLevel level) Sets attribute indicating whether linker should produce verbose output, and at what logging level that output should be shown.- Parameters:
- level- level logging level at which to show linker's verbose output, or- nullto disable verbose output
- See Also:
- getVerboseLevel()
 
 - 
getDestDirpublic java.io.File getDestDir() Required attribute containing directory where linked image will be created.- Returns:
- directory where linked image will reside
- See Also:
- setDestDir(File)
 
 - 
setDestDirpublic void setDestDir(java.io.File dir) Sets attribute indicating directory where linked image will be created.- Parameters:
- dir- directory in which image will be created by linker
- See Also:
- getDestDir()
 
 - 
getCompresspublic Link.CompressionLevel getCompress() Attribute indicating level of compression linker will apply to image. This is exclusive with regard tocreateCompress(): only one of the two may be specified.- Returns:
- compression level to apply, or nullfor none
- See Also:
- setCompress(Link.CompressionLevel),- createCompress()
 
 - 
setCompresspublic void setCompress(Link.CompressionLevel level) Sets attribute indicating level of compression linker will apply to image. This is exclusive with regard tocreateCompress(): only one of the two may be specified.- Parameters:
- level- compression level to apply, or- nullfor none
- See Also:
- getCompress(),- createCompress()
 
 - 
createCompresspublic 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. This is exclusive with regard to thecompressattribute: only one of the two may be specified.- Returns:
- new, unconfigured child element
- See Also:
- setCompress(Link.CompressionLevel)
 
 - 
getEndiannesspublic Link.Endianness getEndianness() Attribute which indicates whether certain files in the linked image will be big-endian or little-endian. Ifnull, the underlying platform's endianness is used.- Returns:
- endianness to apply, or nullto platform default
- See Also:
- setEndianness(Link.Endianness)
 
 - 
setEndiannesspublic void setEndianness(Link.Endianness endianness) Sets attribute which indicates whether certain files in the linked image will be big-endian or little-endian. Ifnull, the underlying platform's endianness is used.- Parameters:
- endianness- endianness to apply, or- nullto use platform default
- See Also:
- getEndianness()
 
 - 
getCheckDuplicateLegalpublic 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.- Returns:
- true if legal notice files with same name should be checked for identical content, false to suppress check
- See Also:
- setCheckDuplicateLegal(boolean)
 
 - 
setCheckDuplicateLegalpublic 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.- Parameters:
- check- true if legal notice files with same name should be checked for identical content, false to suppress check
- See Also:
- getCheckDuplicateLegal()
 
 - 
getVmTypepublic Link.VMType getVmType() Attribute indicating what type of JVM the linked image should have. Ifnull, all JVM types are included.- Returns:
- type of JVM linked image will have
- See Also:
- setVmType(Link.VMType)
 
 - 
setVmTypepublic void setVmType(Link.VMType type) Set attribute indicating what type of JVM the linked image should have. Ifnull, all JVM types are included.- Parameters:
- type- type of JVM linked image will have
- See Also:
- getVmType()
 
 - 
createReleaseInfopublic Link.ReleaseInfo createReleaseInfo() Creates child<releaseInfo>element that modifies the default release properties of the linked image.- Returns:
- new, unconfigured child element
 
 - 
executepublic void execute() throws BuildExceptionInvokes 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.- Overrides:
- executein class- Task
- Throws:
- BuildException- if destDir is not set
- BuildException- if module path is unset or empty
- BuildException- if module list is empty
- BuildException- if compressionLevel attribute and compression child element are both specified
 
 
- 
 
-