I am trying to upgrade Gradle wrapper for a projec...
# community-support
a
I am trying to upgrade Gradle wrapper for a project from 6.8.3 to 8.10.0 My system gradle version is also 6.8.3 As per the documentation to update the wrapper and relevant files we need to run gradle wrapper command twice. Below is what I am trying to run :
Copy code
gradle wrapper --gradle-version 8.10
But this only updates the gradle-wrapper.properties to use the 8.10 distributionUrl and leaves the gradle-wrapper.jar untouched even though I run the command twice. I see the older jar of 6.8.3. However, if I try to set my gradle path locally to 8.10 and run the above command, then it updates the gradle-wrapper.jar too to that of gradle 8.10. What I have observed is that the choice gradle-wrapper.jar file is dependent on the currently set gradle version (not gradle wrapper). I am not sure where I could be going wrong. I would have expected the wrapper task to generate the gardle-wrapper.jar file specific to the version that I specify with "--gradle-version" parameter
c
./gradlew wrapper …
thank you 1
v
To expand a little on what @Chris Lee said, as you already found out that far as far as I can tell from your text, the
--gradle-version
parameter just controls which version is written to the properties file and thus the Gradle version used to run the build when properly using the wrapper. It is not to be confused with the Gradle wrapper version, that is the four files that are written to disk, including the wrapper jar. While newer versions of the wrapper might have improvements or bug fixes, usually also older wrappers can start newer Gradle versions and vice versa. And also not every Gradle version has a different wrapper jar, you see the checksums for the wrapper jar that is included with each Gradle version on https://gradle.org/release-checksums/. Which Gradle wrapper files are written to disk depends on the Gradle version currently executed. This also is exactly the reason why to run the
wrapper
task twice. The first call just updates the version in the properties file (and overwrites the four wrapper files with the version from the old Gradle version when using the wrapper or from the version you actually run for example when not using the wrapper), the second call - when typically using the Gradle wrapper to call the wrapper task - would then use the newly updated Gradle version and thus write the new wrapper files to disk.
❤️ 1
a
@Chris Lee That indeed resolved the issue.
@Vampire Thank you so much for the explanation. Gradle is beautiful in its own way. I have learned it the hard way. 🙂 I understand gradle wrappers do not change quite often, but in some cases older wrappers might just not work. Recently I faced an issue while trying to build a pretty old gradle project in an environment that restricts anonymous GET requests. My gradle-wrapper download always returned 401. Passing credentials via gradle.properties/distributionUrl never worked. Given the fact that nothing changed in the project, I became suspicious of the wrapper.jar and thought of performing a diff against a more recent wrapper jar and I found the issue to be with the gradle-wrapper.jar file itself. It turned out that the olde gradle-wrapper jar had no support for Baisc auth(the org.gradle.wrapper.Download class)
👌 1