4.2 Wrapper#distributionType not working


(steve) #1

I am trying to use Gradle 4.2. I have the following Wrapper task:

task wrapper(type: Wrapper) {
    gradleVersion = '4.2'
    // grab sources, docs as well... better IDE integration
    distributionType = DistributionType.ALL
}

For sure, shell is picking up 4.2:

[sebersole@t460p java8]$ /home/sebersole/.gradle/wrapper/dists/gradle-4.2-bin/cl9xe1l8k8ophj72k8rv6xbu7/gradle-4.2/bin/gradle --version

------------------------------------------------------------
Gradle 4.2
------------------------------------------------------------

Build time:   2017-09-20 14:48:23 UTC
Revision:     5ba503cc17748671c83ce35d7da1cffd6e24dfbd

Groovy:       2.4.11
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.8.0_121 (Oracle Corporation 25.121-b13)
OS:           Linux 4.10.9-200.fc25.x86_64 amd64

But I get:

[sebersole@t460p java8]$ /home/sebersole/.gradle/wrapper/dists/gradle-4.2-bin/cl9xe1l8k8ophj72k8rv6xbu7/gradle-4.2/bin/gradle wrapper

FAILURE: Build failed with an exception.

* Where:
Build file '/home/sebersole/projects/sebersole/java8/andrea-playground/java8/build.gradle' line: 104

* What went wrong:
A problem occurred evaluating project ':java8'.
> Could not get unknown property 'DistributionType' for task ':java8:wrapper' of type org.gradle.api.tasks.wrapper.Wrapper.
...

Anyone know what I am doing wrong?


(steve) #2

Sorry, no idea why the code blocks are being render so fugly. That is not how I have it in the source


(Sterling Greene) #3

DistributionType is an inner class of Wrapper and it’s not a part of the default imports (but probably should be). Did this work at some point? I tried 3.2 and 4.x and see the same behavior.

There’s an implicit conversion between String -> enum types, so you can just do:

wrapper {
   distributionType = "ALL"
}

You can also import the type:

import org.gradle.api.tasks.wrapper.Wrapper.DistributionType

wrapper {
   distributionType = DistributionType.ALL
}

(steve) #4

The String version worked for me. Thanks Sterling.

And no, I just saw this setting and it scratched an itch I have had for some time because IntelliJ at least does some extras when it sees the dist sources.