# Class Wrapper

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
org.gradle.api.tasks.wrapper.Wrapper

All Implemented Interfaces:
  `Comparable<Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.TaskInternal, Named, ExtensionAware, Task, Configurable<Task>`

@DisableCachingByDefault(because="Updating the wrapper is not worth caching") public abstract class Wrapper extends 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 delegate to this JAR.

Since:
  0.7

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `Wrapper.DistributionType`
  Specifies the Gradle distribution type.
  `static enum`
  `Wrapper.PathBase`
  Specifies how the wrapper path should be interpreted.

  ### Nested classes/interfaces inherited from interface Named

  `Named.Namer`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `DEFAULT_DISTRIBUTION_PARENT_NAME`
  The default distribution parent name.

  ### Fields inherited from interface Task

  `TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Wrapper()`
  Creates a new `Wrapper`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `(package private) void`
  `generate()`
  `Wrapper.PathBase`
  `getArchiveBase()`
  The archive base specifies whether the unpacked wrapper distribution should be stored in the project or in the gradle user home dir.
  `String`
  `getArchivePath()`
  Returns the path where the gradle distributions archive should be saved (i.e.
  `List<Wrapper.DistributionType>`
  `getAvailableDistributionTypes()`
  Deprecated.
  Since 9.3.0.
  `File`
  `getBatchScript()`
  Returns the file to write the wrapper batch script to.
  `Wrapper.PathBase`
  `getDistributionBase()`
  The distribution base specifies whether the unpacked wrapper distribution should be stored in the project or in the gradle user home dir.
  `String`
  `getDistributionPath()`
  Returns the path where the gradle distributions needed by the wrapper are unzipped.
  `@Nullable String`
  `getDistributionSha256Sum()`
  The SHA-256 hash sum of the gradle distribution.
  `Wrapper.DistributionType`
  `getDistributionType()`
  Returns the type of the Gradle distribution to be used by the wrapper.
  `String`
  `getDistributionUrl()`
  The URL to download the gradle distribution from.
  `protected abstract org.gradle.api.internal.file.FileLookup`
  `getFileLookup()`
  `String`
  `getGradleVersion()`
  Returns the gradle version for the wrapper.
  `File`
  `getJarFile()`
  Returns the file to write the wrapper jar file to.
  `abstract Property<Integer>`
  `getNetworkTimeout()`
  The network timeout specifies how many ms to wait for when the wrapper is performing network operations, such as downloading the wrapper jar.
  `File`
  `getPropertiesFile()`
  Returns the file to write the wrapper properties to.
  `abstract Property<Integer>`
  `getRetries()`
  The number of retries to attempt when downloading the Gradle distribution.
  `abstract Property<Integer>`
  `getRetryBackOffMs()`
  The initial back off in milliseconds to wait between download retries.
  `File`
  `getScriptFile()`
  Returns the file to write the wrapper script to.
  `abstract Property<Boolean>`
  `getValidateDistributionUrl()`
  Indicates if this task will validate the distribution url that has been configured.
  `void`
  `setArchiveBase(Wrapper.PathBase archiveBase)`
  The archive base specifies whether the unpacked wrapper distribution should be stored in the project or in the gradle user home dir.
  `void`
  `setArchivePath(String archivePath)`
  Set's the path where the gradle distributions archive should be saved (i.e.
  `void`
  `setDistributionBase(Wrapper.PathBase distributionBase)`
  The distribution base specifies whether the unpacked wrapper distribution should be stored in the project or in the gradle user home dir.
  `void`
  `setDistributionPath(String distributionPath)`
  Sets the path where the gradle distributions needed by the wrapper are unzipped.
  `void`
  `setDistributionSha256Sum(@Nullable String distributionSha256Sum)`
  The SHA-256 hash sum of the gradle distribution.
  `void`
  `setDistributionType(Wrapper.DistributionType distributionType)`
  The type of the Gradle distribution to be used by the wrapper.
  `void`
  `setDistributionUrl(String url)`
  The URL to download the gradle distribution from.
  `void`
  `setGradleVersion(String gradleVersion)`
  The version of the gradle distribution required by the wrapper.
  `void`
  `setJarFile(File jarFile)`
  The file to write the wrapper jar file to.
  `void`
  `setJarFile(Object jarFile)`
  The file to write the wrapper jar file to.
  `void`
  `setScriptFile(File scriptFile)`
  The file to write the wrapper script to.
  `void`
  `setScriptFile(Object scriptFile)`
  The file to write the wrapper script to.

  ### Methods inherited from class DefaultTask

  `compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService`

  ### Methods inherited from class org.gradle.api.internal.AbstractTask

  `acceptServiceReferences, appendParallelSafeAction, doNotTrackState, doNotTrackStateIf, getAsDynamicObject, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getLoggingManager, getOnlyIf, getReasonNotToTrackState, getReasonsNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, restoreOnlyIf, restoreTaskActions, service, setImpliesSubProjects`

  ### Methods inherited from class Object

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

  ### Methods inherited from interface Task

  `doNotTrackState, notCompatibleWithConfigurationCache, service`

- ## Field Details

  - ### DEFAULT_DISTRIBUTION_PARENT_NAME

    public static final String DEFAULT_DISTRIBUTION_PARENT_NAME
    The default distribution parent name.
    Since:
      0.7
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### Wrapper

    public Wrapper()
    Creates a new `Wrapper`.
    Since:
      0.9

- ## Method Details

  - ### generate

    void generate()

  - ### getScriptFile

    @OutputFile public File getScriptFile()
    Returns the file to write the wrapper script to.
    Since:
      0.9

  - ### setScriptFile

    public void setScriptFile(File scriptFile)
    The file to write the wrapper script to.
    Since:
      4.0

  - ### setScriptFile

    public void setScriptFile(Object scriptFile)
    The file to write the wrapper script to.
    Since:
      0.9

  - ### getBatchScript

    @OutputFile public File getBatchScript()
    Returns the file to write the wrapper batch script to.
    Since:
      1.0

  - ### getJarFile

    @OutputFile public File getJarFile()
    Returns the file to write the wrapper jar file to.
    Since:
      0.9

  - ### setJarFile

    public void setJarFile(File jarFile)
    The file to write the wrapper jar file to.
    Since:
      4.0

  - ### setJarFile

    public void setJarFile(Object jarFile)
    The file to write the wrapper jar file to.
    Since:
      0.9

  - ### getPropertiesFile

    @OutputFile public File getPropertiesFile()
    Returns the file to write the wrapper properties to.
    Since:
      0.9

  - ### getDistributionPath

    @Input public String getDistributionPath()
    Returns the path where the gradle distributions needed by the wrapper are unzipped. The path is relative to the distribution base directory
    Since:
      0.7
    See Also:
      - `setDistributionPath(String)`

  - ### setDistributionPath

    public void setDistributionPath(String distributionPath)
    Sets the path where the gradle distributions needed by the wrapper are unzipped. The path is relative to the distribution base directory
    Since:
      0.7
    See Also:
      - `setDistributionPath(String)`

  - ### getGradleVersion

    @Input public String getGradleVersion()
    Returns the gradle version for the wrapper.
    Throws:
      `GradleException` - if the label that can be provided via `setGradleVersion(String)` can not be resolved at the moment. For example, there is not a `release-candidate` available at all times.
    Since:
      0.7
    See Also:
      - `setGradleVersion(String)`

  - ### setGradleVersion

    public void setGradleVersion(String gradleVersion)
    The version of the gradle distribution required by the wrapper. This is usually the same version of Gradle you use for building your project. The following labels are allowed to specify a version: `latest`, `release-candidate`, `release-milestone`, `release-nightly`, and `nightly`

    The resulting distribution url is validated before it is written to the gradle-wrapper.properties file.

    Since:
      0.7

  - ### getDistributionType

    @Input public Wrapper.DistributionType getDistributionType()
    Returns the type of the Gradle distribution to be used by the wrapper.
    Since:
      3.1
    See Also:
      - `setDistributionType(DistributionType)`

  - ### setDistributionType

    public void setDistributionType(Wrapper.DistributionType distributionType)
    The type of the Gradle distribution to be used by the wrapper. By default, this is `Wrapper.DistributionType.BIN`, which is the binary-only Gradle distribution without documentation.
    Since:
      3.1
    See Also:
      - `Wrapper.DistributionType`

  - ### getAvailableDistributionTypes

    @Internal @Deprecated public List<Wrapper.DistributionType> getAvailableDistributionTypes()
    Deprecated.
    Since 9.3.0. Use `Wrapper.DistributionType.values()` directly instead.
    The list of available gradle distribution types. Always returns the contents of `Wrapper.DistributionType.values()`.
    Since:
      3.1

  - ### getDistributionUrl

    @Input public String getDistributionUrl()
    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.

    Since:
      0.9.1

  - ### setDistributionUrl

    public void setDistributionUrl(String url)
    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 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.

    The distribution url is validated before it is written to the gradle-wrapper.properties file.

    Since:
      0.9.1

  - ### getDistributionSha256Sum

    @Optional @Input public @Nullable String getDistributionSha256Sum()
    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.

    Since:
      4.5

  - ### setDistributionSha256Sum

    public void setDistributionSha256Sum(@Nullable String distributionSha256Sum)
    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.

    Since:
      4.5

  - ### getDistributionBase

    @Input public Wrapper.PathBase getDistributionBase()
    The distribution base specifies whether the unpacked wrapper distribution should be stored in the project or in the gradle user home dir.
    Since:
      0.7

  - ### setDistributionBase

    public void setDistributionBase(Wrapper.PathBase distributionBase)
    The distribution base specifies whether the unpacked wrapper distribution should be stored in the project or in the gradle user home dir.
    Since:
      0.7

  - ### getArchivePath

    @Input public String getArchivePath()
    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.
    Since:
      0.7

  - ### setArchivePath

    public void setArchivePath(String archivePath)
    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()`.
    Since:
      0.7

  - ### getArchiveBase

    @Input public Wrapper.PathBase getArchiveBase()
    The archive base specifies whether the unpacked wrapper distribution should be stored in the project or in the gradle user home dir.
    Since:
      0.7

  - ### setArchiveBase

    public void setArchiveBase(Wrapper.PathBase archiveBase)
    The archive base specifies whether the unpacked wrapper distribution should be stored in the project or in the gradle user home dir.
    Since:
      0.7

  - ### getNetworkTimeout

    @Input @Optional public abstract Property<Integer> getNetworkTimeout()
    The network timeout specifies how many ms to wait for when the wrapper is performing network operations, such as downloading the wrapper jar.
    Since:
      7.6

  - ### getRetries

    @Input @Incubating @Optional public abstract Property<Integer> getRetries()
    The number of retries to attempt when downloading the Gradle distribution. If a download fails, the wrapper will attempt to download it again up to the specified number of times.
    Returns:
      The number of retries property.
    Since:
      9.5.0

  - ### getRetryBackOffMs

    @Input @Incubating @Optional public abstract Property<Integer> getRetryBackOffMs()
    The initial back off in milliseconds to wait between download retries. After a failed download attempt, the wrapper will wait for this amount of time before attempting the next retry, doubling the delay on each subsequent failure.
    Returns:
      The initial retry back off property in milliseconds.
    Since:
      9.5.0

  - ### getValidateDistributionUrl

    @Incubating @Input public abstract Property<Boolean> getValidateDistributionUrl()
    Indicates if this task will validate the distribution url that has been configured.
    Returns:
      whether this task will validate the distribution url
    Since:
      8.2

  - ### getFileLookup

    @Inject protected abstract org.gradle.api.internal.file.FileLookup getFileLookup()