Skip to content

Conversation

@hugoncosta
Copy link

Following the discussion in square/okhttp#9032 and the PR in square/okhttp#9040, the purpose of this change is to ensure Okio remains compatible with Kotlin 2.0.

My change is only within the Okio package - to make the entire project compatible, there would need to be a few changes in other modules, more specifically adapting the usage of the new Kotlin Clock (see https://github.com/search?q=repo%3Asquare%2Fokio%20kotlin.time.Clock&type=code).

@hugoncosta hugoncosta force-pushed the kotlin2.0Compatibility branch 2 times, most recently from fab61f7 to 70db5ce Compare August 30, 2025 13:48
@hugoncosta hugoncosta force-pushed the kotlin2.0Compatibility branch from 70db5ce to 1d2a05a Compare August 30, 2025 13:51
@hugoncosta
Copy link
Author

Similar to the OkHttp PR mentioned above, limiting the scope of this change by only ensuring that the source sets remain compatible with Kotlin 2.0 - tests, which are already using 2.1+ features (like the new Clock and Instant) can remain on the latest version.

Comment on lines +66 to +73
// Some sourceSets do not end with Test, easier to use the negative
matching { !it.name.endsWith("Test") }.all {
// Setting these to allow for backwards compatibility
languageSettings {
apiVersion = "2.0"
languageVersion = "2.0"
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Some sourceSets do not end with Test, easier to use the negative
matching { !it.name.endsWith("Test") }.all {
// Setting these to allow for backwards compatibility
languageSettings {
apiVersion = "2.0"
languageVersion = "2.0"
}
}
tasks.withType<KotlinCompile>().configureEach {
if (name.contains("test")) return@configureEach // Skip test source sets.
compilerOptions {
// Pin language level to 2.0 to ensure compatibility with older Gradle versions and other libraries that depend on okhttp.
// https://docs.gradle.org/current/userguide/compatibility.html#kotlin
languageVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0
apiVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants