okhttp icon indicating copy to clipboard operation
okhttp copied to clipboard

Set apiVersion and languageVersion to 2.0 to ensure backwards compatibility

Open hugoncosta opened this issue 4 months ago • 6 comments

Address #9032 by setting apiVersion and languageVersion to 2.0. This ensures that the code can be compiled with Kotlin 2.2.0+ but users as low as 1.9.0 are able to run this without being forced to update. For reference, 2.2.0 supports compilation as low as 1.6.0.

Compiled locally, seems to work fine, but my laptop is not setup to compile the Android modules btw

hugoncosta avatar Aug 28 '25 15:08 hugoncosta

Sorry about that - not really used to these workflows + I don't have an Android SDK on my machine. I think this should be it 🤞

hugoncosta avatar Aug 30 '25 13:08 hugoncosta

I think I have found an easier path, and especially one that doesn't require us to change much - the source code is already 2.0 compatible, only the tests aren't, and they don't need to be, so why bother? The change is now focusing only on "main" source sets, leaving the tests to use any 2.0+ feature.

hugoncosta avatar Aug 30 '25 16:08 hugoncosta

I'll wait for https://github.com/square/okio/pull/1690 to land before this

yschimke avatar Oct 02 '25 08:10 yschimke

The Okio PR sounds promising, so I'll land this assuming it will also. Thanks for the PR.

Are you ok with the suggested changes for matching tasks I accepted? They are also on the Okio PR.

yschimke avatar Nov 26 '25 08:11 yschimke

Shit, I think that suggestion broke it.

Not sure if we need to follow this https://kotlinlang.org/docs/whatsnew21.html#new-api-for-kotlin-gradle-plugin-extensions

yschimke avatar Nov 26 '25 08:11 yschimke

Yeah, we can try out something like

extensions.configure<KotlinBaseExtension> {
  (this as HasConfigurableKotlinCompilerOptions<*>?)?.let {
    compilerOptions {
      apiVersion = KotlinVersion.KOTLIN_2_0
      languageVersion = KotlinVersion.KOTLIN_2_0
    }
  }
}

Goooler avatar Nov 26 '25 08:11 Goooler