-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Set apiVersion and languageVersion to 2.0 for backwards compatibility #1690
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
base: master
Are you sure you want to change the base?
Conversation
fab61f7 to
70db5ce
Compare
70db5ce to
1d2a05a
Compare
|
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. |
| // 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" | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // 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 | |
| } | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This caused some issues committing to the OkHttp PR
|
You probably also want to set the |
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).