title: How to set the distribution type in the wrapper task
body: <p>This seems like it should be simple but I just can't get it to work. I'm trying to set the <code>distributionType</code> property of the wrapper task, but it's not working:</p>
  
  <pre class="lang-groovy prettyprint-override"><code>task wrapper(type: Wrapper) {
      gradleVersion = '4.1'
      distributionType = DistributionType.ALL
  }
  </code></pre>
  
  <p>When I try to run the wrapper task, I get the following error:</p>
  
  <pre class="lang-none prettyprint-override"><code>$ gradle wrapper
  
  FAILURE: Build failed with an exception.
  
  * Where:
  Build file '.../build.gradle' line: 6
  
  * What went wrong:
  A problem occurred evaluating root project 'project'.
  &gt; Could not get unknown property 'DistributionType' for task ':wrapper' of type org.gradle.api.tasks.wrapper.Wrapper.
  
  * Try:
  Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  
  BUILD FAILED
  
  Total time: 0.613 secs
  </code></pre>
  
  <p>And note that I've downloaded the latest Gradle version (4.1) and added it to my bash path:</p>
  
  <pre class="lang-none prettyprint-override"><code>$ gradle -version
  
  ------------------------------------------------------------
  Gradle 4.1
  ------------------------------------------------------------
  
  Build time:   2017-08-07 14:38:48 UTC
  Revision:     941559e020f6c357ebb08d5c67acdb858a3defc2
  
  Groovy:       2.4.11
  Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
  JVM:          1.8.0_144 (Oracle Corporation 25.144-b01)
  OS:           Mac OS X 10.12.6 x86_64
  </code></pre>
  
  <p>The way I'm trying to set it seems reasonable, since it's the same way I'm setting the <code>gradleVersion</code>, and given the implementation of  <a href="https://github.com/gradle/gradle/blob/d4133a7e85046ed2c6f677739043487f38a83898/subprojects/build-init/src/main/java/org/gradle/api/tasks/wrapper/Wrapper.java" rel="noreferrer"><code>Wrapper.java</code></a>:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class Wrapper extends DefaultTask {
  
      public enum DistributionType {
          /**
           * binary-only Gradle distribution without sources and documentation
           */
          BIN,
          /**
           * complete Gradle distribution with binaries, sources and documentation
           */
          ALL
      }
  
      //...
  
      public void setGradleVersion(String gradleVersion) {
          this.gradleVersion = GradleVersion.version(gradleVersion);
      }
  
      // ...
  
      public void setDistributionType(DistributionType distributionType) {
          this.distributionType = distributionType;
      }
  
      // ...
  
  }
  </code></pre>
  
  <p>I have seen this workaround (as described in <a href="https://stackoverflow.com/a/38113324/1354590">this</a> StackOverflow answer), which works, but it feels a little too hacky...</p>
  
  <pre class="lang-groovy prettyprint-override"><code>task wrapper(type: Wrapper) {
      gradleVersion = '2.13'
      distributionUrl = distributionUrl.replace("bin", "all")
  }
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>I have also re-run with <code>--stacktrace --debug</code>. Rather than posting the entire output (which is quite large), I'll post what appears to be the most relevant part:</p>
  
  <pre class="lang-none prettyprint-override"><code>&gt; Could not get unknown property 'DistributionType' for task ':wrapper' of type org.gradle.api.tasks.wrapper.Wrapper.
  
  * Exception is:
  org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'slackscheduler'.
    at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:92)
    at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$2.run(DefaultScriptPluginFactory.java:176)
    at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:77)
    // many, many lines omitted
  Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'DistributionType' for task ':wrapper' of type org.gradle.api.tasks.wrapper.Wrapper.
    at org.gradle.internal.metaobject.AbstractDynamicObject.getMissingProperty(AbstractDynamicObject.java:85)
    at org.gradle.internal.metaobject.ConfigureDelegate.getProperty(ConfigureDelegate.java:134)
    at build_90tinl1ipqqsdzvv3o3xs2adt$_run_closure1.doCall(/Users/justinrogers/Development/slack-scheduler/build.gradle:6)
    at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:70)
  </code></pre>
  
  <p>Which, at the end of the day, show's that we're failing <a href="https://github.com/gradle/gradle/blob/8b7a5106c9229f1caa8267cf2cdcd9ab6cf4426b/subprojects/core/src/main/java/org/gradle/internal/metaobject/AbstractDynamicObject.java#L45" rel="noreferrer">here</a>.</p>