-
Notifications
You must be signed in to change notification settings - Fork 545
Description
SQLDelight Version
2.0.0-alpha05
Operating System
MacOS arm 64
Gradle Version
8.1.1
Kotlin Version
1.9.0-dev-6609
Dialect
SQLite
AGP Version
No response
Describe the Bug
The Gradle Plugin shadows some dependencies including kotlinx.coroutines
which depending how it ends up being loaded by Gradle can clash with KGP.
The specific problem I bumped into is when using KGP 1.9 previews that are using coroutines:
Caused by: java.lang.NoSuchMethodError: 'kotlin.coroutines.CoroutineContext kotlinx.coroutines.CoroutineContextKt.newCoroutineContext(kotlin.coroutines.CoroutineContext, kotlin.coroutines.CoroutineContext)'
at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:155)
at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
at org.jetbrains.kotlin.gradle.plugin.KotlinPluginLifecycleKt.withRestrictedStages(KotlinPluginLifecycle.kt:237)
at org.jetbrains.kotlin.gradle.targets.metadata.KotlinMetadataTargetConfigurator$createMetadataCompilationsForCommonSourceSets$1.invokeSuspend(KotlinMetadataTargetConfigurator.kt:187)
The version of coroutines that is shaded is coroutines 1.5.2
, transitively included by intelliJ core:
./gradlew :sqldelight-gradle-plugin:dependencies --configuration shade
shade
+--- com.jetbrains.intellij.platform:core:221.6008.13
| +--- com.jetbrains.intellij.platform:util:221.6008.13
| | +--- org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.5.2
| | | \--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2
| | | \--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.2
And the problem is that the 1.5.2
version of coroutines doesn't contain fun CoroutineContext.newCoroutineContext(CoroutineContext) added in 1.6.1
A quick fix is to explicitly shade a newer version (1.6.4
or so) but that still feels fragile as this version (as well as other shaded dependencies) need to be tracked and updated manually.
Another fix would be to relocate at the same time as shadowing, possibly using R8 to avoid bumping into GradleUp/shadow#232. If there's interest, I could look into that last option, let me know.
Stacktrace
No response
Gradle Build Script
No response