Can I ask KGP to set `kotlin-stdlib` version of my...
# gradle
m
Can I ask KGP to set
kotlin-stdlib
version of my project to a specific version for the JVM but not for other targets? I have used
coreLibrariesVersion
in the past but this has a lot of side effects, especially for targets like JS/Wasm that currently require their
kotlin-stdlib
to be aligned with the compiler version.
t
in KMP project?
m
yep
I'd like something like
jvmCoreLibrariesVersion
or something like so
Or maybe just for stdlib
jvmKotlinStdlibVersion
t
though
kotlin-stdlib-common
will enforce newer stdlib version in JVM target
so I would say - no, it is not possible
m
mmm, so if I explicitely do this:
Copy code
coreLibrariesVersion = "2.0.0"

sourceSets.getByName("wasmJsMain")  {
  dependencies {
    implementation("org.jetbrains.kotlin:kotlin-stdlib:2.2.0")
  }
}
Then my JVM compile classpath will get
2.2.0
no matter what?
Nevermind, that seems to work ok
That seems to work ok
t
other way around by having lower version in
coreLibrariesVersion
may work. Though in general I would advice to not mix stdlib versions
m
other way around by having lower version in
coreLibrariesVersion
may work
This is what I'm doing (I think?)
coreLibrariesVersion
is 2.0.0 I "upgrade" it explicitely to "2.2.0" in the dependencies for wasmJsMain
Though in general I would advice to not mix stdlib versions
It's an issue for compatibility because if I update everything to 2.2.0, I lose the JVM 2.0.0 consumers
Which is a pity considering the JVM supports both
apiVersion
and
languageVersion
t
State is following: • KGP adds
kotlin-stdlib*
dependencies automatically • If there is a dependency explicitly specified - KGP skips this logic •
kotlin-stdlib-common
has a dependency on
kotlin-stdlib
So if
coreLibrariesVersion
is lower than explicit added dependency - it works
thank you color 1
m
Gotcha. Would you be open to a setting that sets the JVM
kotlinStdlibVersion
separately from
coreLibrariesVersion
?
Or maybe 2 settings for JVM vs non-JVM? •
jvmCoreLibrariesVersion
nonJvmCoreLibrariesVersion
(I know that feels uhhhh... 😅 )
Because right now it feels a bit fragile. I'm duplicating some of the KGP logic and I'm not even sure there aren't other wasm/js libraries that need to be upgraded
t
I doubt - it is a workaround for compatibility problem in Kotlin
and better to solve compatibility problem
m
Yea but this might take a while I think?
Anyways, I'll go with that and we'll see where that takes us. Thanks for the insights!
t
Adding DSL and supporting it also takes an effort 🙂
m
I hear you 💯 :)