api / org.gradle.api.tasks.wrapper / Wrapper

Wrapper

open class Wrapper : DefaultTask

Generates scripts (for *nix and windows) which allow you to build your project with Gradle, without having to install Gradle.

When a user executes a wrapper script the first time, the script downloads and installs the appropriate Gradle distribution and runs the build against this downloaded distribution. Any installed Gradle distribution is ignored when using the wrapper scripts.

The scripts generated by this task are intended to be committed to your version control system. This task also generates a small gradle-wrapper.jar bootstrap JAR file and properties file which should also be committed to your VCS. The scripts delegates to this JAR.

Types

DistributionType

class DistributionType

Specifies the Gradle distribution type.

PathBase

class PathBase

Specifies how the wrapper path should be interpreted.

Constructors

<init>

Wrapper()

Properties

DEFAULT_DISTRIBUTION_PARENT_NAME

static val DEFAULT_DISTRIBUTION_PARENT_NAME: String

Functions

getArchiveBase

open fun getArchiveBase(): PathBase

The archive base specifies whether the unpacked wrapper distribution should be stored in the project or in the gradle user home dir.

getArchivePath

open fun getArchivePath(): String

Returns the path where the gradle distributions archive should be saved (i.e. the parent dir). The path is relative to the archive base directory.

getAvailableDistributionTypes

open fun getAvailableDistributionTypes(): MutableList<DistributionType>

The list of available gradle distribution types.

getBatchScript

open fun getBatchScript(): File

Returns the file to write the wrapper batch script to.

getDistributionBase

open fun getDistributionBase(): PathBase

The distribution base specifies whether the unpacked wrapper distribution should be stored in the project or in the gradle user home dir.

getDistributionPath

open fun getDistributionPath(): String

Returns the path where the gradle distributions needed by the wrapper are unzipped. The path is relative to the distribution base directory

getDistributionSha256Sum

open fun getDistributionSha256Sum(): String

The SHA-256 hash sum of the gradle distribution.

If not set, the hash sum of the gradle distribution is not verified.

The wrapper allows for verification of the downloaded Gradle distribution via SHA-256 hash sum comparison. This increases security against targeted attacks by preventing a man-in-the-middle attacker from tampering with the downloaded Gradle distribution.

getDistributionType

open fun getDistributionType(): DistributionType

Returns the type of the Gradle distribution to be used by the wrapper.

getDistributionUrl

open fun getDistributionUrl(): String

The URL to download the gradle distribution from.

If not set, the download URL is the default for the specified #getGradleVersion().

If #getGradleVersion() is not set, will return null.

The wrapper downloads a certain distribution only once and caches it. If your distribution base is the project, you might submit the distribution to your version control system. That way no download is necessary at all. This might be in particular interesting, if you provide a custom gradle snapshot to the wrapper, because you don't need to provide a download server then.

getGradleVersion

open fun getGradleVersion(): String

Returns the gradle version for the wrapper.

getJarFile

open fun getJarFile(): File

Returns the file to write the wrapper jar file to.

getPropertiesFile

open fun getPropertiesFile(): File

Returns the file to write the wrapper properties to.

getScriptFile

open fun getScriptFile(): File

Returns the file to write the wrapper script to.

setArchiveBase

open fun setArchiveBase(archiveBase: PathBase): Unit

The archive base specifies whether the unpacked wrapper distribution should be stored in the project or in the gradle user home dir.

setArchivePath

open fun setArchivePath(archivePath: String): Unit

Set's the path where the gradle distributions archive should be saved (i.e. the parent dir). The path is relative to the parent dir specified with #getArchiveBase().

setDistributionBase

open fun setDistributionBase(distributionBase: PathBase): Unit

The distribution base specifies whether the unpacked wrapper distribution should be stored in the project or in the gradle user home dir.

setDistributionPath

open fun setDistributionPath(distributionPath: String): Unit

Sets the path where the gradle distributions needed by the wrapper are unzipped. The path is relative to the distribution base directory

setDistributionSha256Sum

open fun setDistributionSha256Sum(distributionSha256Sum: String): Unit

The SHA-256 hash sum of the gradle distribution.

If not set, the hash sum of the gradle distribution is not verified.

The wrapper allows for verification of the downloaded Gradle distribution via SHA-256 hash sum comparison. This increases security against targeted attacks by preventing a man-in-the-middle attacker from tampering with the downloaded Gradle distribution.

setDistributionType

open fun setDistributionType(distributionType: DistributionType): Unit

The type of the Gradle distribution to be used by the wrapper. By default, this is DistributionType#BIN, which is the binary-only Gradle distribution without documentation.

setDistributionUrl

open fun setDistributionUrl(url: String): Unit

The URL to download the gradle distribution from.

If not set, the download URL is the default for the specified #getGradleVersion().

If #getGradleVersion() is not set, will return null.

The wrapper downloads a certain distribution only once and caches it. If your distribution base is the project, you might submit the distribution to your version control system. That way no download is necessary at all. This might be in particular interesting, if you provide a custom gradle snapshot to the wrapper, because you don't need to provide a download server then.

setGradleVersion

open fun setGradleVersion(gradleVersion: String): Unit

The version of the gradle distribution required by the wrapper. This is usually the same version of Gradle you use for building your project.

setJarFile

open fun setJarFile(jarFile: File): Unit
open fun setJarFile(jarFile: Any): Unit

The file to write the wrapper jar file to.

setScriptFile

open fun setScriptFile(scriptFile: File): Unit
open fun setScriptFile(scriptFile: Any): Unit

The file to write the wrapper script to.