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:
- Cloneable
Assembles jmod files into an executable image.  Equivalent to the
 JDK 
jlink command.
 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:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionclassChild element fully describing compression of a linked image.static classPossible attribute values for compression level of a linked image:0noneno compression (default)1stringsconstant string sharing2zipzip compressionstatic classPossible values for linked image endianness:littleandbig.classChild element representing a custom launcher command in a linked image.classChild element that contains a pattern matching Java locales.classChild element that explicitly names a Java module.classChild element type which specifies a jlink files pattern.classChild element describing changes to the default release properties of a linked image.classGrandchild element describing additional release info properties for a linked image.classGrandchild element representing deletable key in a linked image's release properties.static classPossible values for JVM type in linked image:client,server,minimal, orall.
- 
Field SummaryFields inherited from class org.apache.tools.ant.ProjectComponentdescription, location, project
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionCreates child<compress>element that specifies the level of compression the linker will apply, and optionally, which files in the image will be compressed.Creates child<excludeFiles>element that specifies files to exclude from linked modules when assembling linked image.Creates child<excludeResources>element that specifies resources in linked modules that will be excluded from linked image.Creates child<launcher>element that can contain information on additional executable in the linked image.Creates child<locale>element that specifies a Java locale, or set of locales, to include from thejdk.localedatamodule in the linked image.Adds child<module>element, specifying a module to link.Adds child<modulePath>element.Creates child<observableModule>element that represents one of the modules the linker is permitted to know about.Creates child<releaseInfo>element that modifies the default release properties of the linked image.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.booleanAttribute indicating whether linked image should pull in providers in the module path of services used by explicitly linked modules.booleanAttribute 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.Attribute indicating level of compression linker will apply to image.booleangetDebug()Attribute indicating whether linker should keep or strip debug information in classes.Required attribute containing directory where linked image will be created.Attribute which indicates whether certain files in the linked image will be big-endian or little-endian.booleanAttribute indicating whether linker should allow modules made from signed jars.booleanAttribute indicating whether to include header files from linked modules in image.booleanAttribute indicating whether to include man pages from linked modules in image.booleanAttribute indicating whether to include generated native commands, and native commands from linked modules, in image.Attribute containing path of directories containing linkable modules.Attribute indicating whether linker should produce verbose output, and at what logging level that output should be shown.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(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(String patternList) Sets attribute containing a list of patterns denoting files to exclude from linked modules when assembling linked image.voidsetExcludeResources(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(String launcherList) Sets attribute containing comma-separated list of information needed for additional executables in the linked image.voidsetLocales(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.voidSets module path as a reference.voidsetModules(String moduleList) Sets attribute containing list of modules to link.voidsetObservableModules(String moduleList) Sets attribute containing modules linker is permitted to know about.voidsetResourceOrder(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, setTaskTypeMethods inherited from class org.apache.tools.ant.ProjectComponentclone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
- 
Constructor Details- 
Linkpublic Link()
 
- 
- 
Method Details- 
createModulePathAdds child<modulePath>element.- Returns:
- new, empty child element
- See Also:
 
- 
getModulePathAttribute containing path of directories containing linkable modules.- Returns:
- current module path, possibly null
- See Also:
 
- 
setModulePathSets attribute containing path of directories containing linkable modules.- Parameters:
- path- new module path
- See Also:
 
- 
setModulePathRefSets module path as a reference.- Parameters:
- ref- path reference
- See Also:
 
- 
createModuleAdds child<module>element, specifying a module to link.- Returns:
- new, unconfigured child element
- See Also:
 
- 
setModulesSets attribute containing list of modules to link.- Parameters:
- moduleList- comma-separated list of module names
 
- 
createObservableModuleCreates child<observableModule>element that represents one of the modules the linker is permitted to know about.- Returns:
- new, unconfigured child element
 
- 
setObservableModulesSets attribute containing modules linker is permitted to know about.- Parameters:
- moduleList- comma-separated list of module names
 
- 
createLauncherCreates child<launcher>element that can contain information on additional executable in the linked image.- Returns:
- new, unconfigured child element
- See Also:
 
- 
setLaunchersSets 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
 
- 
createLocaleCreates 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
 
- 
setLocalesSets 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
 
- 
createExcludeFilesCreates child<excludeFiles>element that specifies files to exclude from linked modules when assembling linked image.- Returns:
- new, unconfigured child element
- See Also:
 
- 
setExcludeFilesSets 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:
 
- 
createExcludeResourcesCreates child<excludeResources>element that specifies resources in linked modules that will be excluded from linked image.- Returns:
- new, unconfigured child element
- See Also:
 
- 
setExcludeResourcesSets 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:
 
- 
createResourceOrderCreates child<resourceOrderelement that specifies explicit ordering of resources in linked image.- Returns:
- new, unconfigured child element
- See Also:
 
- 
setResourceOrderSets 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:
 
- 
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:
 
- 
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:
 
- 
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:
 
- 
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:
 
- 
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:
 
- 
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:
 
- 
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:
 
- 
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:
 
- 
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:
 
- 
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:
 
- 
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:
 
- 
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:
 
- 
getVerboseLevelAttribute 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:
 
- 
setVerboseLevelSets 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:
 
- 
getDestDirRequired attribute containing directory where linked image will be created.- Returns:
- directory where linked image will reside
- See Also:
 
- 
setDestDirSets attribute indicating directory where linked image will be created.- Parameters:
- dir- directory in which image will be created by linker
- See Also:
 
- 
getCompressAttribute 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:
 
- 
setCompressSets 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:
 
- 
createCompressCreates 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:
 
- 
getEndiannessAttribute 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:
 
- 
setEndiannessSets 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:
 
- 
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:
 
- 
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:
 
- 
getVmTypeAttribute 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:
 
- 
setVmTypeSet 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:
 
- 
createReleaseInfoCreates child<releaseInfo>element that modifies the default release properties of the linked image.- Returns:
- new, unconfigured child element
 
- 
executeInvokes 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
 
 
-