api / org.gradle.jvm.tasks / Jar

Jar

@Incubating open class Jar : Zip

Assembles a JAR archive.

Constructors

<init>

Jar()

Properties

DEFAULT_EXTENSION

static val DEFAULT_EXTENSION: String

Inherited Properties

ZIP_EXTENSION

static val ZIP_EXTENSION: String

Functions

getManifest

open fun getManifest(): Manifest

Returns the manifest for this JAR archive.

getManifestContentCharset

open fun getManifestContentCharset(): String

The character set used to encode the manifest content. Defaults to UTF-8. You can change this property but it is not recommended as JVMs expect manifests content to be encoded using UTF-8.

getMetaInf

open fun getMetaInf(): CopySpec

getMetadataCharset

open fun getMetadataCharset(): String

The character set used to encode JAR metadata like file names. Defaults to UTF-8. You can change this property but it is not recommended as JVMs expect JAR metadata to be encoded using UTF-8

manifest

open fun manifest(configureClosure: Closure<*>): Jar

Configures the manifest for this JAR archive.

The given closure is executed to configure the manifest. The org.gradle.api.java.archives.Manifest is passed to the closure as its delegate.

open fun manifest(configureAction: Action<in Manifest>): Jar

Configures the manifest for this JAR archive.

The given action is executed to configure the manifest.

metaInf

open fun metaInf(configureClosure: Closure<*>): CopySpec

Adds content to this JAR archive's META-INF directory.

The given closure is executed to configure a CopySpec. The org.gradle.api.file.CopySpec is passed to the closure as its delegate.

open fun metaInf(configureAction: Action<in CopySpec>): CopySpec

Adds content to this JAR archive's META-INF directory.

The given action is executed to configure a CopySpec.

setManifest

open fun setManifest(manifest: Manifest): Unit

Sets the manifest for this JAR archive.

setManifestContentCharset

open fun setManifestContentCharset(manifestContentCharset: String): Unit

The character set used to encode the manifest content.

setMetadataCharset

open fun setMetadataCharset(metadataCharset: String): Unit

The character set used to encode JAR metadata like file names. Defaults to UTF-8. You can change this property but it is not recommended as JVMs expect JAR metadata to be encoded using UTF-8

Inherited Functions

getEntryCompression

open fun getEntryCompression(): ZipEntryCompression

Returns the compression level of the entries of the archive. If set to ZipEntryCompression#DEFLATED (the default), each entry is compressed using the DEFLATE algorithm. If set to ZipEntryCompression#STORED the entries of the archive are left uncompressed.

isZip64

open fun isZip64(): Boolean

Whether the zip can contain more than 65535 files and/or support files greater than 4GB in size.

The standard zip format has hard limits on file size and count. The Zip64 format extension practically removes these limits and is therefore required for building large zips.

However, not all Zip readers support the Zip64 extensions. Notably, the java.util.zip.ZipInputStream JDK class does not support Zip64 for versions earlier than Java 7. This means you should not enable this property if you are building JARs to be used with Java 6 and earlier runtimes.

setEntryCompression

open fun setEntryCompression(entryCompression: ZipEntryCompression): Unit

Sets the compression level of the entries of the archive. If set to ZipEntryCompression#DEFLATED (the default), each entry is compressed using the DEFLATE algorithm. If set to ZipEntryCompression#STORED the entries of the archive are left uncompressed.

setZip64

open fun setZip64(allowZip64: Boolean): Unit

Enables building zips with more than 65535 files or bigger than 4GB.

Inheritors

Jar

open class Jar : Jar

Assembles a JAR archive.