I used task wrapper
when Gradle was 4.x but when I change gradleVersion
to 5.0 , gradle wrapper states that it can't add a task with the same name. This didn't happen when it was 4.x when I could just change from 4.8 to 4.9 without issues. Does Gradle changed how task wrapper
works?
First install Gradle on your machine, then open up your project directory via the command line. Run gradle wrapper and you are done! You can add the --gradle-version X.Y argument to specify which version of Gradle to use.
Defining a custom wrapper
task in your build script has been deprecated since Gradle 4.8 version, see Gradle 4.8 depreciations (section Overwriting Gradle's built-in tasks" section)
Since version 4.8 (and before 5.0) you should have a warning message as below if you still define a custom wrapper
task:
$ ./gradlew clean --warning-mode all
> Configure project :
Creating a custom task named 'wrapper' has been deprecated and is scheduled to be removed in Gradle 5.0.
You can configure the existing task using the 'wrapper { }' syntax or create your custom task under a different name.'.
As announced, the support for custom wrapper
task has been removed in Gradle 5.0, so you need to use the new way for configuring the Wrapper:
// Configuring the wrapper, the old way (gradle < 4.8 )
// see https://docs.gradle.org/4.4/userguide/gradle_wrapper.html#sec:wrapper_generation
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionType = Wrapper.DistributionType.BIN
}
// Configuring the wrapper, the new way (since Gradle 4.8)
// see https://docs.gradle.org/current/userguide/gradle_wrapper.html#customizing_wrapper
wrapper{
gradleVersion = '5.1'
distributionType = Wrapper.DistributionType.BIN
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With