Slackbot
10/20/2022, 4:59 PMVampire
10/20/2022, 6:40 PMEric Kolotyluk
10/20/2022, 7:06 PMtask wrapper(type: Wrapper) {
gradleVersion = '7.5.1'
}
I just looked that up on https://stackoverflow.com/questions/22778139/how-to-define-gradle-version-to-use-inside-build-gradle. Is there a better way to do this?
Up until now, I thought we had to upgrade the wrapper itself with
gradle wrapper
which upgrades the local wrapper to the same version as the installed Gradle. This is actually problematic...Vampire
10/20/2022, 7:14 PMwrapper instead of configuring the existing one. And besides the face that you do not leverage task configuration avoidance (I recommend you read the doc chapter about it, out of scope here).
It is correct that the wrapper task or the 4 wrapper files in place, taken from the currently running Gradle version. So if you want to update Gradle to 7.5.1 and also the wrapper files to the latest version, you would run ./gradlew wrapper --gradle-version 7.5.1 --gradle-distribution-sha256-sum f6b8596b10cce501591e92f229816aa4046424f3b24d771751b06779d58c8ec4 twice. First to update the Gradle version and then again to update the wrapper files from that new version.Vampire
10/20/2022, 7:15 PMgradle ... I do not even have any Gradle version installed. Every project not having the wrapper files imho has a bug.Vampire
10/20/2022, 7:16 PMgradle wrapper you indeed get the wrapper files of the latest version as that is what you are running. But having to have it installed just for that is imho unnecessary when you can simply run the task with the wrapper twice to get the same resultEric Kolotyluk
10/20/2022, 7:16 PMgradle wrapper
When this succeeds, if I do ./gradlew --version it reports back as 7.5.1
I only use the local gradle to upgrade the wrapper...Eric Kolotyluk
10/20/2022, 7:18 PMVampire
10/20/2022, 7:26 PMgradle runs a 7.5.1 the only difference is that you do not have the sha256 checksum set.
Maybe your misunderstanding is, that ./gradlew --version does not give you the version of the wrapper.
The wrapper does not have a displayable version.
That command gives you the version of the Gradle version running as that is what is relevant for the build.
The wrapper is just for downloading the necessary Gradle version if necessary, verifying its sha256 sum if you have set it and running it to execute the build.Vampire
10/20/2022, 7:27 PMEric Kolotyluk
10/20/2022, 7:32 PM./gradlew --version, it reports an old version...
After I do gradle wrapper and it succeeds, if I do ./gradlew --version it reports the latest version...Vampire
10/20/2022, 7:33 PMEric Kolotyluk
10/20/2022, 7:46 PMMaybe your misunderstanding is, thatSo, why the change in version reported?does not give you the version of the wrapper../gradlew --version
Eric Kolotyluk
10/20/2022, 7:49 PMVampire
10/20/2022, 7:55 PMwrapper task writes the four wrapper files.
gradlew, gradlew.bat, and gradle/wrapper/gradle-wrapper.jar from the currently running version of Gradle.
gradle/wrapper/gradle-wrapper.properties with content that among other things contains the Gradle version used to run the build if the wrapper is used.
The default version for that value is also the currently running version of Gradle, but can be overwritten using config in the build script (does not make much sense) or commandline parameter.
So assuming you have there 7.1, then ./gradlew --version will report 7.1.
If you then do gradle wrapper where gradle runs a 7.5.1, the wrapper files are updated with the new version and from 7.5.1, so ./gradlew --version report 7.5.1 and the wrapper is latest version.
If gradle runs a Gradle version 6.5 but you have the config in the build script you showed that configures version to 7.5.1, then the wrapper files written will be from version 6.5 but the version in gradle-wrapper.properties will be 7.5.1, so ./gradlew --version will also show 7.5.1.
If you have still 7.1 in the gradle-wrapper.properties, and then do ./gradlew wrapper --gradle-version 7.5.1 --gradle-distribution-sha256 ..., the wrapper files written will be from 7.1, but the version in gradle-wrapper.properties will be 7.5.1, if you then execute it a second time, the wrapper files written will also be from 7.5.1 as now 7.5.1 is the version used to execute the build.Eric Kolotyluk
10/20/2022, 7:59 PMVampire
10/20/2022, 8:01 PMEric Kolotyluk
10/20/2022, 8:07 PMgradle to upgrade the wrapper...
Sorry, the process you describe is way too complex... it may be more robust, but I try to avoid unnecessary cognitive load...Chris Lee
10/20/2022, 8:09 PM./gradlew wrapper --gradle-version 7.5.1
./gradlew wrapperEric Kolotyluk
10/20/2022, 8:11 PMsha256 stuff...
I will try your method next time I do and upgrade, to see if it solves other problems I am having...Vampire
10/20/2022, 8:12 PMI don't configure the Gradle version in the gradle.build file. I was asking if I should, based on StackOverflow advice...SO is full of bad advice. ๐
I always use the wrapper...๐
I only use the localSo not always, but why? Just use the wrapper as I suggestedto upgrade the wrapper...gradle
Sorry, the process you describe is way too complexIt is too complex to execute two simple commands? o_O
Vampire
10/20/2022, 8:12 PMI was talking about all thatIf you don't care about safety, just omit that parameterstuff...sha256
Vampire
10/20/2022, 8:13 PMVampire
10/20/2022, 8:13 PMChris Lee
10/20/2022, 8:13 PMVampire
10/20/2022, 8:14 PMVampire
10/20/2022, 8:15 PM./gradlew wrapper --gradle-version 7.5.1 --gradle-distribution-sha256-sum f6b8596b10cce501591e92f229816aa4046424f3b24d771751b06779d58c8ec4 && ./gradlew wrapper --gradle-version 7.5.1 --gradle-distribution-sha256-sum f6b8596b10cce501591e92f229816aa4046424f3b24d771751b06779d58c8ec4
or
./gradlew wrapper --gradle-version 7.5.1 && ./gradlew wrapper
if safety is not any concernEric Kolotyluk
10/20/2022, 8:15 PMEric Kolotyluk
10/20/2022, 8:15 PMChris Lee
10/20/2022, 8:16 PMVampire
10/20/2022, 8:16 PMEric Kolotyluk
10/20/2022, 8:16 PMVampire
10/20/2022, 8:16 PMEric Kolotyluk
10/20/2022, 8:17 PMVampire
10/20/2022, 8:17 PMVampire
10/20/2022, 8:17 PMChris Lee
10/20/2022, 8:18 PM