Package org.apache.tools.ant.taskdefs.modules

# Class Jmod

java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.tools.ant.taskdefs.modules.Jmod

All Implemented Interfaces:
  `Cloneable`

public class Jmod extends Task
Creates a linkable .jmod file from a modular jar file, and optionally from other resource files such as native libraries and documents. Equivalent to the JDK's jmod tool.

Supported attributes:

`destFile`
  Required, jmod file to create.
`classpath`
`classpathref`
  Where to locate files to be placed in the jmod file.
`modulepath`
`modulepathref`
  Where to locate dependencies.
`commandpath`
`commandpathref`
  Directories containing native commands to include in jmod.
`headerpath`
`headerpathref`
  Directories containing header files to include in jmod.
`configpath`
`configpathref`
  Directories containing user-editable configuration files to include in jmod.
`legalpath`
`legalpathref`
  Directories containing legal licenses and notices to include in jmod.
`nativelibpath`
`nativelibpathref`
  Directories containing native libraries to include in jmod.
`manpath`
`manpathref`
  Directories containing man pages to include in jmod.
`version`
  Module version.
`mainclass`
  Main class of module.
`platform`
  The target platform for the jmod. A particular JDK's platform can be seen by running `jmod describe $JDK_HOME/jmods/java.base.jmod | grep -i platform`.
`hashModulesPattern`
  Regular expression for names of modules in the module path which depend on the jmod being created, and which should have hashes generated for them and included in the new jmod.
`resolveByDefault`
  Boolean indicating whether the jmod should be one of the default resolved modules in an application. Default is true.
`moduleWarnings`
  Whether to emit warnings when resolving modules which are not recommended for use. Comma-separated list of one of more of the following:
  `deprecated`
    Warn if module is deprecated
  `leaving`
    Warn if module is deprecated for removal
  `incubating`
    Warn if module is an incubating (not yet official) module

Supported nested elements:

`<classpath>`
  Path indicating where to locate files to be placed in the jmod file.
`<modulepath>`
  Path indicating where to locate dependencies.
`<commandpath>`
  Path of directories containing native commands to include in jmod.
`<headerpath>`
  Path of directories containing header files to include in jmod.
`<configpath>`
  Path of directories containing user-editable configuration files to include in jmod.
`<legalpath>`
  Path of directories containing legal notices to include in jmod.
`<nativelibpath>`
  Path of directories containing native libraries to include in jmod.
`<manpath>`
  Path of directories containing man pages to include in jmod.
`<version>`
  Module version of jmod. Must have a required `number` attribute. May also have optional `preRelease` and `build` attributes.
`<moduleWarning>`
  Has one required attribute, `reason`. See `moduleWarnings` attribute above. This element may be specified multiple times.

destFile and classpath are required data.

Since:
  1.10.6

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `Jmod.ResolutionWarningReason`
  Permissible reasons for jmod creation to emit warnings.
  `class`
  `Jmod.ResolutionWarningSpec`
  Child element which enables jmod tool warnings.

- ## Field Summary

  ### Fields inherited from class org.apache.tools.ant.Task

  `target, taskName, taskType, wrapper`

  ### Fields inherited from class org.apache.tools.ant.ProjectComponent

  `description, location, project`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Jmod()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Path`
  `createClasspath()`
  Adds an unconfigured `<classpath>` child element which can specify the files which will comprise the created jmod.
  `Path`
  `createCommandPath()`
  Creates a child element which can contain a list of directories containing native executable files to include in the created jmod.
  `Path`
  `createConfigPath()`
  Creates a child element which can contain a list of directories containing user configuration files to include in the created jmod.
  `Path`
  `createHeaderPath()`
  Creates a child element which can contain a list of directories containing compile-time header files for third party use, to include in the created jmod.
  `Path`
  `createLegalPath()`
  Creates a child element which can contain a list of directories containing license files to include in the created jmod.
  `Path`
  `createManPath()`
  Creates a child element which can contain a list of directories containing man pages (program manuals, typically in troff format) to include in the created jmod.
  `Path`
  `createModulePath()`
  Creates a child `<modulePath>` element which can contain a path of directories containing modules upon which modules in the classpath depend.
  `Jmod.ResolutionWarningSpec`
  `createModuleWarning()`
  Creates a child element which can specify the circumstances under which jmod creation emits warnings.
  `Path`
  `createNativeLibPath()`
  Creates a child element which can contain a list of directories containing native libraries to include in the created jmod.
  `ModuleVersion`
  `createVersion()`
  Creates an uninitialized child element representing the version of the module represented by the created jmod.
  `void`
  `execute()`
  Creates a jmod file according to this task's properties and child elements.
  `Path`
  `getClasspath()`
  Attribute which specifies the files (usually modular .jar files) which will comprise the created jmod file.
  `Path`
  `getCommandPath()`
  Attribute containing path of directories which contain native executable files to include in the created jmod.
  `Path`
  `getConfigPath()`
  Attribute containing list of directories which contain user configuration files.
  `File`
  `getDestFile()`
  Attribute containing the location of the jmod file to create.
  `String`
  `getHashModulesPattern()`
  Attribute containing a regular expression which specifies which of the modules that depend on the jmod being created should have hashes generated and added to the jmod.
  `Path`
  `getHeaderPath()`
  Attribute containing a path of directories which hold compile-time header files for third party use, all of which will be included in the created jmod.
  `Path`
  `getLegalPath()`
  Attribute containing list of directories which hold license files to include in the created jmod.
  `String`
  `getMainClass()`
  Attribute containing the class that acts as the executable entry point of the created jmod.
  `Path`
  `getManPath()`
  Attribute containing list of directories containing man pages to include in created jmod.
  `Path`
  `getModulePath()`
  Attribute containing path of directories which contain modules on which the created jmod's constituent modules depend.
  `Path`
  `getNativeLibPath()`
  Attribute containing list of directories which hold native libraries to include in the created jmod.
  `String`
  `getPlatform()`
  Attribute containing the platform for which the jmod will be built.
  `boolean`
  `getResolveByDefault()`
  Attribute indicating whether the created jmod should be visible in a module path, even when not specified explicitly.
  `String`
  `getVersion()`
  Attribute which specifies a module version for created jmod.
  `void`
  `setClasspath(Path path)`
  Sets attribute specifying the files that will comprise the created jmod file.
  `void`
  `setClasspathRef(Reference ref)`
  Sets classpath attribute from a path reference.
  `void`
  `setCommandPath(Path path)`
  Sets attribute containing path of directories which contain native executable files to include in the created jmod.
  `void`
  `setCommandPathRef(Reference ref)`
  Sets command path from a path reference.
  `void`
  `setConfigPath(Path path)`
  Sets attribute containing list of directories which contain user configuration files.
  `void`
  `setConfigPathRef(Reference ref)`
  Sets configuration file path from a path reference.
  `void`
  `setDestFile(File file)`
  Sets attribute containing the location of the jmod file to create.
  `void`
  `setHashModulesPattern(String pattern)`
  Sets attribute containing a regular expression which specifies which of the modules that depend on the jmod being created should have hashes generated and added to the jmod.
  `void`
  `setHeaderPath(Path path)`
  Sets attribute containing a path of directories which hold compile-time header files for third party use, all of which will be included in the created jmod.
  `void`
  `setHeaderPathRef(Reference ref)`
  Sets header path from a path reference.
  `void`
  `setLegalPath(Path path)`
  Sets attribute containing list of directories which hold license files to include in the created jmod.
  `void`
  `setLegalPathRef(Reference ref)`
  Sets legal licenses path from a path reference.
  `void`
  `setMainClass(String className)`
  Sets attribute containing the class that acts as the executable entry point of the created jmod.
  `void`
  `setManPath(Path path)`
  Sets attribute containing list of directories containing man pages to include in created jmod.
  `void`
  `setManPathRef(Reference ref)`
  Sets man pages path from a path reference.
  `void`
  `setModulePath(Path path)`
  Sets attribute containing path of directories which contain modules on which the created jmod's constituent modules depend.
  `void`
  `setModulePathRef(Reference ref)`
  Sets module path from a path reference.
  `void`
  `setModuleWarnings(String warningList)`
  Sets attribute containing a comma-separated list of reasons for jmod creation to emit warnings.
  `void`
  `setNativeLibPath(Path path)`
  Sets attribute containing list of directories which hold native libraries to include in the created jmod.
  `void`
  `setNativeLibPathRef(Reference ref)`
  Sets native library path from a path reference.
  `void`
  `setPlatform(String platform)`
  Sets attribute containing the platform for which the jmod will be built.
  `void`
  `setResolveByDefault(boolean resolve)`
  Sets attribute indicating whether the created jmod should be visible in a module path, even when not specified explicitly.
  `void`
  `setVersion(String version)`
  Sets the module version for the created jmod.

  ### Methods inherited from class org.apache.tools.ant.Task

  `bindToOwner, 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.ProjectComponent

  `clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject`

  ### Methods inherited from class java.lang.Object

  `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Jmod

    public Jmod()

- ## Method Details

  - ### getDestFile

    public File getDestFile()
    Attribute containing the location of the jmod file to create.
    Returns:
      location of jmod file
    See Also:
      - `setDestFile(File)`

  - ### setDestFile

    public void setDestFile(File file)
    Sets attribute containing the location of the jmod file to create. This value is required.
    Parameters:
      `file` - location where jmod file will be created.

  - ### createClasspath

    public Path createClasspath()
    Adds an unconfigured `<classpath>` child element which can specify the files which will comprise the created jmod.
    Returns:
      new, unconfigured child element
    See Also:
      - `setClasspath(Path)`

  - ### getClasspath

    public Path getClasspath()
    Attribute which specifies the files (usually modular .jar files) which will comprise the created jmod file.
    Returns:
      path of constituent files
    See Also:
      - `setClasspath(Path)`

  - ### setClasspath

    public void setClasspath(Path path)
    Sets attribute specifying the files that will comprise the created jmod file. Usually this contains a single modular .jar file.

    The classpath is required and must not be empty.

    Parameters:
      `path` - path of files that will comprise jmod
    See Also:
      - `createClasspath()`

  - ### setClasspathRef

    public void setClasspathRef(Reference ref)
    Sets classpath attribute from a path reference.
    Parameters:
      `ref` - reference to path which will act as classpath

  - ### createModulePath

    public Path createModulePath()
    Creates a child `<modulePath>` element which can contain a path of directories containing modules upon which modules in the classpath depend.
    Returns:
      new, unconfigured child element
    See Also:
      - `setModulePath(Path)`

  - ### getModulePath

    public Path getModulePath()
    Attribute containing path of directories which contain modules on which the created jmod's constituent modules depend.
    Returns:
      path of directories containing modules needed by classpath modules
    See Also:
      - `setModulePath(Path)`

  - ### setModulePath

    public void setModulePath(Path path)
    Sets attribute containing path of directories which contain modules on which the created jmod's constituent modules depend.
    Parameters:
      `path` - path of directories containing modules needed by classpath modules
    See Also:
      - `createModulePath()`

  - ### setModulePathRef

    public void setModulePathRef(Reference ref)
    Sets module path from a path reference.
    Parameters:
      `ref` - reference to path which will act as module path

  - ### createCommandPath

    public Path createCommandPath()
    Creates a child element which can contain a list of directories containing native executable files to include in the created jmod.
    Returns:
      new, unconfigured child element
    See Also:
      - `setCommandPath(Path)`

  - ### getCommandPath

    public Path getCommandPath()
    Attribute containing path of directories which contain native executable files to include in the created jmod.
    Returns:
      list of directories containing native executables
    See Also:
      - `setCommandPath(Path)`

  - ### setCommandPath

    public void setCommandPath(Path path)
    Sets attribute containing path of directories which contain native executable files to include in the created jmod.
    Parameters:
      `path` - list of directories containing native executables
    See Also:
      - `createCommandPath()`

  - ### setCommandPathRef

    public void setCommandPathRef(Reference ref)
    Sets command path from a path reference.
    Parameters:
      `ref` - reference to path which will act as command path

  - ### createConfigPath

    public Path createConfigPath()
    Creates a child element which can contain a list of directories containing user configuration files to include in the created jmod.
    Returns:
      new, unconfigured child element
    See Also:
      - `setConfigPath(Path)`

  - ### getConfigPath

    public Path getConfigPath()
    Attribute containing list of directories which contain user configuration files.
    Returns:
      list of directories containing user configuration files
    See Also:
      - `setConfigPath(Path)`

  - ### setConfigPath

    public void setConfigPath(Path path)
    Sets attribute containing list of directories which contain user configuration files.
    Parameters:
      `path` - list of directories containing user configuration files
    See Also:
      - `createConfigPath()`

  - ### setConfigPathRef

    public void setConfigPathRef(Reference ref)
    Sets configuration file path from a path reference.
    Parameters:
      `ref` - reference to path which will act as configuration file path

  - ### createHeaderPath

    public Path createHeaderPath()
    Creates a child element which can contain a list of directories containing compile-time header files for third party use, to include in the created jmod.
    Returns:
      new, unconfigured child element
    See Also:
      - `setHeaderPath(Path)`

  - ### getHeaderPath

    public Path getHeaderPath()
    Attribute containing a path of directories which hold compile-time header files for third party use, all of which will be included in the created jmod.
    Returns:
      path of directories containing header files

  - ### setHeaderPath

    public void setHeaderPath(Path path)
    Sets attribute containing a path of directories which hold compile-time header files for third party use, all of which will be included in the created jmod.
    Parameters:
      `path` - path of directories containing header files
    See Also:
      - `createHeaderPath()`

  - ### setHeaderPathRef

    public void setHeaderPathRef(Reference ref)
    Sets header path from a path reference.
    Parameters:
      `ref` - reference to path which will act as header path

  - ### createLegalPath

    public Path createLegalPath()
    Creates a child element which can contain a list of directories containing license files to include in the created jmod.
    Returns:
      new, unconfigured child element
    See Also:
      - `setLegalPath(Path)`

  - ### getLegalPath

    public Path getLegalPath()
    Attribute containing list of directories which hold license files to include in the created jmod.
    Returns:
      path containing directories which hold license files

  - ### setLegalPath

    public void setLegalPath(Path path)
    Sets attribute containing list of directories which hold license files to include in the created jmod.
    Parameters:
      `path` - path containing directories which hold license files
    See Also:
      - `createLegalPath()`

  - ### setLegalPathRef

    public void setLegalPathRef(Reference ref)
    Sets legal licenses path from a path reference.
    Parameters:
      `ref` - reference to path which will act as legal path

  - ### createNativeLibPath

    public Path createNativeLibPath()
    Creates a child element which can contain a list of directories containing native libraries to include in the created jmod.
    Returns:
      new, unconfigured child element
    See Also:
      - `setNativeLibPath(Path)`

  - ### getNativeLibPath

    public Path getNativeLibPath()
    Attribute containing list of directories which hold native libraries to include in the created jmod.
    Returns:
      path of directories containing native libraries

  - ### setNativeLibPath

    public void setNativeLibPath(Path path)
    Sets attribute containing list of directories which hold native libraries to include in the created jmod.
    Parameters:
      `path` - path of directories containing native libraries
    See Also:
      - `createNativeLibPath()`

  - ### setNativeLibPathRef

    public void setNativeLibPathRef(Reference ref)
    Sets native library path from a path reference.
    Parameters:
      `ref` - reference to path which will act as native library path

  - ### createManPath

    public Path createManPath()
    Creates a child element which can contain a list of directories containing man pages (program manuals, typically in troff format) to include in the created jmod.
    Returns:
      new, unconfigured child element
    See Also:
      - `setManPath(Path)`

  - ### getManPath

    public Path getManPath()
    Attribute containing list of directories containing man pages to include in created jmod. Man pages are textual program manuals, typically in troff format.
    Returns:
      path containing directories which hold man pages to include in jmod

  - ### setManPath

    public void setManPath(Path path)
    Sets attribute containing list of directories containing man pages to include in created jmod. Man pages are textual program manuals, typically in troff format.
    Parameters:
      `path` - path containing directories which hold man pages to include in jmod
    See Also:
      - `createManPath()`

  - ### setManPathRef

    public void setManPathRef(Reference ref)
    Sets man pages path from a path reference.
    Parameters:
      `ref` - reference to path which will act as module path

  - ### createVersion

    public ModuleVersion createVersion()
    Creates an uninitialized child element representing the version of the module represented by the created jmod.
    Returns:
      new, unconfigured child element
    See Also:
      - `setVersion(String)`

  - ### getVersion

    public String getVersion()
    Attribute which specifies a module version for created jmod.
    Returns:
      module version for created jmod

  - ### setVersion

    public void setVersion(String version)
    Sets the module version for the created jmod.
    Parameters:
      `version` - module version of created jmod
    See Also:
      - `createVersion()`

  - ### getMainClass

    public String getMainClass()
    Attribute containing the class that acts as the executable entry point of the created jmod.
    Returns:
      fully-qualified name of jmod's main class

  - ### setMainClass

    public void setMainClass(String className)
    Sets attribute containing the class that acts as the executable entry point of the created jmod.
    Parameters:
      `className` - fully-qualified name of jmod's main class

  - ### getPlatform

    public String getPlatform()
    Attribute containing the platform for which the jmod will be built. Platform values are defined in the `java.base.jmod` of JDKs, and usually take the form OS`-`architecture. If unset, current platform is used.
    Returns:
      OS and architecture for which jmod will be built, or `null`

  - ### setPlatform

    public void setPlatform(String platform)
    Sets attribute containing the platform for which the jmod will be built. Platform values are defined in the `java.base.jmod` of JDKs, and usually take the form OS`-`architecture. If unset, current platform is used.

    A JDK's platform can be viewed with a command like: `jmod describe $JDK_HOME/jmods/java.base.jmod | grep -i platform`. o *

    Parameters:
      `platform` - platform for which jmod will be created, or `null`

  - ### getHashModulesPattern

    public String getHashModulesPattern()
    Attribute containing a regular expression which specifies which of the modules that depend on the jmod being created should have hashes generated and added to the jmod.
    Returns:
      regex specifying which dependent modules should have their generated hashes included

  - ### setHashModulesPattern

    public void setHashModulesPattern(String pattern)
    Sets attribute containing a regular expression which specifies which of the modules that depend on the jmod being created should have hashes generated and added to the jmod.
    Parameters:
      `pattern` - regex specifying which dependent modules should have their generated hashes included

  - ### getResolveByDefault

    public boolean getResolveByDefault()
    Attribute indicating whether the created jmod should be visible in a module path, even when not specified explicitly. True by default.
    Returns:
      whether jmod should be visible in module paths

  - ### setResolveByDefault

    public void setResolveByDefault(boolean resolve)
    Sets attribute indicating whether the created jmod should be visible in a module path, even when not specified explicitly. True by default.
    Parameters:
      `resolve` - whether jmod should be visible in module paths

  - ### createModuleWarning

    public Jmod.ResolutionWarningSpec createModuleWarning()
    Creates a child element which can specify the circumstances under which jmod creation emits warnings.
    Returns:
      new, unconfigured child element
    See Also:
      - `setModuleWarnings(String)`

  - ### setModuleWarnings

    public void setModuleWarnings(String warningList)
    Sets attribute containing a comma-separated list of reasons for jmod creation to emit warnings. Valid values in list are: `deprecated`, `leaving`, `incubating`.
    Parameters:
      `warningList` - list containing one or more of the above values, separated by commas
    See Also:
      - `createModuleWarning()`
      - `Jmod.ResolutionWarningReason`

  - ### execute

    public void execute() throws BuildException
    Creates a jmod file according to this task's properties and child elements.
    Overrides:
      `execute` in class `Task`
    Throws:
      `BuildException` - if destFile is not set
      `BuildException` - if classpath is not set or is empty
      `BuildException` - if any path other than classpath refers to an existing file which is not a directory
      `BuildException` - if both `version` attribute and `<version>` child element are present
      `BuildException` - if `hashModulesPattern` is set, but module path is not defined