Creates a JAR archive with the specified contents.
The task is based on the ZIP archive creation saker.zip.create() task with additional features for Java Archive creation.The archive will be written to the specified location in the saker.jar.create subdirectory of the build directory.
By default, the archive is constructed in a deterministic manner, meaning that it will not include timestamps of the current build time, and the entries are put in the archive in a deterministic order.
Summary
Includes | Specifies one or more archive entry inclusions which should be added to the output archive. |
Manifest | Specifies JAR Manifest attributes to be injected into the created archive. |
ModificationTime | Specifies the default modification time of the entries that are placed in the output archive. |
ModuleInfoMainClass | Specifies a Java main class name that should be injected into the module-info.class entry. |
ModuleInfoVersion | Specifies a version that should be injected into the module-info.class entry. |
MultiReleaseContents | Specifies the Multi-Release contents of the created JAR file. |
Output | Specifies the output path of the created archive. |
Resources | Specifies one or more resources which should be added to the created archive. |
Services | Specifies Java services that should be declared by the created Java Archive. |
Transformers | Specifies one or more ZIP resource transformers that should be used when constructing the output. |
Parameters
Collection of ZipIncludeTaskOption
Aliases:
Include
Specifies one or more archive entry inclusions which should be added to the output archive.
The parameter is used to include entries from other ZIP archives into the output.
The option accepts simple paths, file locations, file collections or complex configuration.
Specifies JAR Manifest attributes to be injected into the created archive.
Any attributes specified in this option will result in them being injected into the META-INF/MANIFEST.MF Manifest entry in the archive.
If a manifest entry was not specified using resources, a new one will be added to the archive.
The Manifest-Version: 1.0 required attribute is automatically added if missing.
If a specified value for an attribute is null, it will be removed.
Specifies the default modification time of the entries that are placed in the output archive.
The archive entries which are specified using the Resources parameter will have their modification time set to the date specified using this parameter. This is in order to have deterministic binary outputs of the archives.
If not specified, the epoch date (1970-01-01T00:00:00Z) is used.
Note that this parameter doesn't apply to entries included using the Include parameter. Those entries have the same modification time as in the source Archive.
The format of this parameter should be any of the following:
yyyy-MM-dd HH:mm:ss.SSS
yyyy-MM-dd HH:mm:ss
yyyy-MM-dd HH:mm
yyyy-MM-dd
yyyy.MM.dd
Where the pattern letters are interpreted the same way as SimpleDateFormat: https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html
Specifies a Java main class name that should be injected into the module-info.class entry.
The specified class name will be recorded in the module-info of the created JAR. If there's no module-info.class entry in the output, the attribute is not injected.
The format of the class name is not validated.
Specifies a version that should be injected into the module-info.class entry.
The specified version will be recorded in the module-info of the created JAR. If there's no module-info.class entry in the output, the attribute is not injected.
The format of the version is not validated.
Specifies the Multi-Release contents of the created JAR file.
Multi-Release JAR files can be used to include JRE version specific files in a JAR which are only used if the given runtime major version is greater or equals to the specified requirement.
The option allows specifying contents for the different releases. Each entry in the configuration must have an integer key that specifies the target major version, and the value which contains the resource configurations to include.
Each resource configuration will be placed under the META-INF/versions/<target-major> directory. Any further target directory configurations will be appended after the specified version root directory.
Specifying this option will cause the Multi-Release: true attribute value to be injected into the created JAR Manifest file. (Only if not present yet.)
For more information about Multi-Release JARs: https://openjdk.java.net/jeps/238
Specifies the output path of the created archive.
The path must be forward relative, and the task will write the archive under the saker.jar.create subdirectory of the build directory.
If not specified, the archive is created with the "output.jar" name.
Collection of ZipResourcesTaskOption
Specifies one or more resources which should be added to the created archive.
The option accepts simple paths, file locations, file collections or complex configuration.
The path that a resource is added with to the archive is determined by the type of the configuration.
Specifies Java services that should be declared by the created Java Archive.
The service declarations are Java implementation class names in the META-INF/services/<service-class-name> entry.
In this parameter services entries can be specified for which one or more implementations can be set. These implementation declarations will be injected in the resulting archive.
See ServiceLoader class for more information: https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html
Collection of ZipResourceTransformerTaskOption
Aliases:
Transformer
Specifies one or more ZIP resource transformers that should be used when constructing the output.
ZIP resource transformers are plugins into the archive creating operation. They can customize the archive output in an implementation dependent manner.
In order to add transformers to the task, you need to implement your own Transformer with the ZIP creator task API, or use an existing implementations. Consult the use-case documentation of your transformer of interest to find out how to include it in the task.