What’s the preferred way to customize the wrapper task?

I found two way as follow.

the 1st way:

wrapper {
    gradleVersion "7.6"
    distributionType Wrapper.DistributionType.ALL
}

the 2nd way:

tasks.named("wrapper", Wrapper) {
    gradleVersion "7.6"
    distributionType Wrapper.DistributionType.ALL
}

Which is preferred?

The second is preferable, as it leverages task-configuration avoidance, while the first one does not.

And as a sidenote, please do not use the -all distribution.
There is exactly one situation where it is helpful.
If you use Groovy DSL build scripts and only while actually editing these Groovy DSL build scripts to work-around an IDE shortcoming.
For all other situations it is just a waste of time, bandwidth and disk space for everyone and everything just executing the build.
Actually I’d recommend using the Kotlin DSL anyway, then there is also no reason to use the -all distribution at all anymore, while also gaining type-safe build scripts and an amazingly better IDE support if you use a good IDE like IntelliJ. :slight_smile:

1 Like