Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use JetBrains cache-redirector #3650

Merged
merged 10 commits into from
Jun 27, 2024
34 changes: 34 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,40 @@ plugins {

There is an automation script for this routine, see [testDokka.sh.md](scripts/testDokka.sh.md) for details.

### Updating Gradle
adam-enko marked this conversation as resolved.
Show resolved Hide resolved

To update Gradle, follow these steps:

1. Open https://gradle.org/release-checksums/ and copy the "Binary-only (-bin) ZIP"
checksum corresponding to the desired Gradle version.
2. Update `distributionSha256Sum` in [`gradle-wrapper.properties`](gradle/wrapper/gradle-wrapper.properties).
```diff
- distributionSha256Sum=<old checksum>
+ distributionSha256Sum=<new checksum>
```
3. Update `distributionSha256Sum` in the wrapper task in [`build.gradle.kts`](build.gradle.kts).
```diff
tasks.wrapper {
- distributionSha256Sum = "<old checksum>"
+ distributionSha256Sum = "<new checksum>"
}
```
(Why does `distributionSha256Sum` need to be updated in two places? Because
[the Wrapper task fails if `gradle-wrapper.properties` contains `distributionSha256Sum`, but the task configuration does not.](https://docs.gradle.org/current/userguide/gradle_wrapper.html#configuring_checksum_verification))
4. Update Gradle

Run `./gradlew wrapper --gradle-version=x.y.z`
5. ⚠️ Important ⚠️

**Run** `./gradlew wrapper` **again**!

(Yes, really run `wrapper` twice. [Otherwise, Gradle won't update its wrapper files.](https://github.com/gradle/gradle/issues/884))
6. Commit the
[`gradle/wrapper/**`](./gradle/wrapper),
[`gradlew`](gradlew),
and [`gradlew.bat`](gradlew.bat),
files to git (if there are changes).

### Updating public API dump

[Binary Compatibility Validator](https://github.com/Kotlin/binary-compatibility-validator/blob/master/README.md)
Expand Down
21 changes: 8 additions & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,18 @@ fun includedBuildTasks(taskName: String, filter: (IncludedBuild) -> Boolean = {


tasks.wrapper {
val gradleVersion = "8.7"
distributionUrl =
"https://cache-redirector.jetbrains.com/services.gradle.org/distributions/gradle-${gradleVersion}-bin.zip"
// Gradle requires that checksum is defined both in the wrapper task *and* in gradle-wrapper.properties
// Checksums are available here: https://gradle.org/release-checksums/
distributionSha256Sum = "544c35d6bd849ae8a5ed0bcea39ba677dc40f49df7d1835561582da2009b961d"
doLast {
// Manually update the distribution URL to use cache-redirector.
// (Workaround for https://github.com/gradle/gradle/issues/17515)
propertiesFile.writeText(
buildString {
appendLine("# DO NOT MODIFY THIS FILE")
appendLine("#")
appendLine("# To change the Gradle version modify the wrapper task in the root build.gradle.kts")
appendLine("#")
appendLine("# Explanation:")
appendLine("# Normally the easiest way to update Gradle is to edit gradle-wrapper.properties and re-run `gradle wrapper`.")
appendLine("# However, the wrapper task will overwrite the JetBrains cached URL unless it is specified in the task.")
append(propertiesFile.readText())
}
propertiesFile.readText()
.replace(
"https\\://services.gradle.org/",
"https\\://cache-redirector.jetbrains.com/services.gradle.org/",
)
)
}
}
7 changes: 0 additions & 7 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
# DO NOT MODIFY THIS FILE
#
# To change the Gradle version modify the wrapper task in the root build.gradle.kts
#
# Explanation:
# Normally the easiest way to update Gradle is to edit gradle-wrapper.properties and re-run `gradle wrapper`.
# However, the wrapper task will overwrite the JetBrains cached URL unless it is specified in the task.
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=544c35d6bd849ae8a5ed0bcea39ba677dc40f49df7d1835561582da2009b961d
Expand Down
Loading