api / org.gradle.api.tasks.bundling / Zip

Zip

open class Zip : AbstractArchiveTask

Assembles a ZIP archive. The default is to compress the contents of the zip.

Constructors

<init>

Zip()

Properties

ZIP_EXTENSION

static val ZIP_EXTENSION: String

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.

getMetadataCharset

open fun getMetadataCharset(): String

The character set used to encode ZIP metadata like file names. Defaults to the platform's default character set.

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.

setMetadataCharset

open fun setMetadataCharset(metadataCharset: String): Unit

The character set used to encode ZIP metadata like file names. Defaults to the platform's default character set.

setZip64

open fun setZip64(allowZip64: Boolean): Unit

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

Inherited Functions

getAppendix

open fun getAppendix(): String

Returns the appendix part of the archive name, if any.

getArchiveName

open fun getArchiveName(): String

Returns the archive name. If the name has not been explicitly set, the pattern for the name is: [baseName]-[appendix]-[version]-[classifier].[extension]

getArchivePath

open fun getArchivePath(): File

The path where the archive is constructed. The path is simply the destinationDir plus the archiveName.

getBaseName

open fun getBaseName(): String

Returns the base name of the archive.

getClassifier

open fun getClassifier(): String

Returns the classifier part of the archive name, if any.

getDestinationDir

open fun getDestinationDir(): File

Returns the directory where the archive is generated into.

getExtension

open fun getExtension(): String

Returns the extension part of the archive name.

getVersion

open fun getVersion(): String

Returns the version part of the archive name, if any.

into

open fun into(destPath: Any): AbstractArchiveTask

Specifies the destination directory *inside* the archive for the files. The destination is evaluated as per org.gradle.api.Project#file(Object). Don't mix it up with #getDestinationDir() which specifies the output directory for the archive.

open fun into(destPath: Any, configureClosure: Closure<Any>): AbstractArchiveTask
open fun into(destPath: Any, copySpec: Action<in CopySpec>): CopySpec

Creates and configures a child CopySpec with a destination directory *inside* the archive for the files. The destination is evaluated as per org.gradle.api.Project#file(Object). Don't mix it up with #getDestinationDir() which specifies the output directory for the archive.

isPreserveFileTimestamps

open fun isPreserveFileTimestamps(): Boolean

Specifies whether file timestamps should be preserved in the archive.

If false this ensures that archive entries have the same time for builds between different machines, Java versions and operating systems.

isReproducibleFileOrder

open fun isReproducibleFileOrder(): Boolean

Specifies whether to enforce a reproducible file order when reading files from directories.

Gradle will then walk the directories on disk which are part of this archive in a reproducible order independent of file systems and operating systems. This helps Gradle reliably produce byte-for-byte reproducible archives.

setAppendix

open fun setAppendix(appendix: String): Unit

setArchiveName

open fun setArchiveName(name: String): Unit

Sets the archive name.

setBaseName

open fun setBaseName(baseName: String): Unit

setClassifier

open fun setClassifier(classifier: String): Unit

setDestinationDir

open fun setDestinationDir(destinationDir: File): Unit

setExtension

open fun setExtension(extension: String): Unit

setPreserveFileTimestamps

open fun setPreserveFileTimestamps(preserveFileTimestamps: Boolean): Unit

Specifies whether file timestamps should be preserved in the archive.

If false this ensures that archive entries have the same time for builds between different machines, Java versions and operating systems.

setReproducibleFileOrder

open fun setReproducibleFileOrder(reproducibleFileOrder: Boolean): Unit

Specifies whether to enforce a reproducible file order when reading files from directories.

Gradle will then walk the directories on disk which are part of this archive in a reproducible order independent of file systems and operating systems. This helps Gradle reliably produce byte-for-byte reproducible archives.

setVersion

open fun setVersion(version: String): Unit

Inheritors

Jar

open class Jar : Zip

Assembles a JAR archive.