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, ExtensionAware, Task, org.gradle.util.Configurable<Task>

public 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 delegates to this JAR.

  • Nested Class Summary

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

    Nested classes/interfaces inherited from interface org.gradle.api.Task

    Task.Namer
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     

    Fields inherited from interface org.gradle.api.Task

    TASK_ACTION, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    The archive base specifies whether the unpacked wrapper distribution should be stored in the project or in the gradle user home dir.
    Returns the path where the gradle distributions archive should be saved (i.e.
    The list of available gradle distribution types.
    Returns the file to write the wrapper batch script to.
    The distribution base specifies whether the unpacked wrapper distribution should be stored in the project or in the gradle user home dir.
    Returns the path where the gradle distributions needed by the wrapper are unzipped.
    Returns the type of the Gradle distribution to be used by the wrapper.
    The URL to download the gradle distribution from.
    protected org.gradle.api.internal.file.FileLookup
     
    Returns the gradle version for the wrapper.
    Returns the file to write the wrapper jar file to.
    Returns the file to write the wrapper properties to.
    Returns the file to write the wrapper script to.
    void
    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
    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
    The type of the Gradle distribution to be used by the wrapper.
    void
    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 org.gradle.api.DefaultTask

    newInputDirectory, newInputFile, newOutputDirectory, newOutputFile

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

    addValidator, appendParallelSafeAction, compareTo, configure, deleteAllActions, dependsOn, dependsOnTaskDidWork, doFirst, doFirst, doFirst, doLast, doLast, doLast, execute, finalizedBy, getActions, getAnt, getAsDynamicObject, getConvention, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExecuter, getExtensions, getFinalizedBy, getGroup, getIdentityPath, getImpliesSubProjects, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOnlyIf, getOutputs, getPath, getProject, getServices, getShouldRunAfter, getStandardOutputCapture, getState, getTaskActions, getTaskDependencies, getTemporaryDir, getTemporaryDirFactory, getValidators, hasProperty, injectIntoNewInstance, isEnabled, isHasCustomActions, leftShift, mustRunAfter, onlyIf, onlyIf, prependParallelSafeAction, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setExecuter, setFinalizedBy, setGroup, setImpliesSubProjects, setMustRunAfter, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • Wrapper

      public Wrapper()
  • Method Details

    • getFileLookup

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

      @OutputFile public File getScriptFile()
      Returns the file to write the wrapper script to.
    • 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.
    • getBatchScript

      @OutputFile public File getBatchScript()
      Returns the file to write the wrapper batch script to.
    • getJarFile

      @OutputFile public File getJarFile()
      Returns the file to write the wrapper jar file to.
    • 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.
    • getPropertiesFile

      @OutputFile public File getPropertiesFile()
      Returns the file to write the wrapper properties to.
    • 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
      See Also:
    • 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
      See Also:
    • getGradleVersion

      @Input public String getGradleVersion()
      Returns the gradle version for the wrapper.
      See Also:
    • 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.
    • getDistributionType

      @Input public Wrapper.DistributionType getDistributionType()
      Returns the type of the Gradle distribution to be used by the wrapper.
      See Also:
    • 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.
      See Also:
    • getAvailableDistributionTypes

      public List<Wrapper.DistributionType> getAvailableDistributionTypes()
      The list of available gradle distribution types.
    • 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.

    • 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 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.

    • 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.
    • 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.
    • 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.
    • 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().
    • 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.
    • 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.