Skip to content

Set apiVersion and languageVersion to 2.0 to ensure backwards compatibility#9040

Closed
hugoncosta wants to merge 3 commits into
lysine-dev:masterfrom
hugoncosta:kotlin2.0Compatibility
Closed

Set apiVersion and languageVersion to 2.0 to ensure backwards compatibility#9040
hugoncosta wants to merge 3 commits into
lysine-dev:masterfrom
hugoncosta:kotlin2.0Compatibility

Conversation

@hugoncosta

Copy link
Copy Markdown

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

@yschimke yschimke left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is pointless as is, unless you also update okio. OkHttp might be compatible, but it relies on very recent versions of Okio which arent.

Can you start there and we can happily follow their lead. Mostly the same maintainers I know.

https://github.com/square/okio/blob/master/build.gradle.kts

@hugoncosta

Copy link
Copy Markdown
Author

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
hugoncosta force-pushed the kotlin2.0Compatibility branch from 5de0707 to 7581937 Compare August 30, 2025 16:28
@hugoncosta

Copy link
Copy Markdown
Author

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.

Comment thread build.gradle.kts Outdated
@yschimke

yschimke commented Oct 2, 2025

Copy link
Copy Markdown
Collaborator

I'll wait for lysine-dev/okio#1690 to land before this

Co-authored-by: Zongle Wang <wangzongler@gmail.com>
@yschimke

Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Collaborator

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

@Goooler

Goooler commented Nov 26, 2025

Copy link
Copy Markdown
Contributor

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
    }
  }
}

@yschimke

yschimke commented Feb 8, 2026

Copy link
Copy Markdown
Collaborator

Applying 2.1.21 in #9322

@yschimke yschimke closed this Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants