https://kotlinlang.org logo
Title
m

mbonnin

08/08/2019, 5:58 PM
Any idea why I need to specify the version explicitely if I depend on
kotlin-stdlib-jdk8
but not for plain
kotlin-stdlib
?
implementation("org.jetbrains.kotlin:kotlin-stdlib")
works but
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
doesn't
o

octylFractal

08/08/2019, 6:31 PM
How are you specifying the version otherwise? via the plugin, or using the BOM?
m

mbonnin

08/08/2019, 6:32 PM
What is BOM ?
I have
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.41")
in my root build.gradle.kts. I guess this is where the version comes from
o

octylFractal

08/08/2019, 6:33 PM
https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-bom/1.3.41 Bill Of Materials, specifies version for all artifacts. Gradle supports this by doing
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.3.41"))
👍 1
m

mbonnin

08/08/2019, 6:33 PM
Ah, nope, I'm not using that
o

octylFractal

08/08/2019, 6:34 PM
I think if you're using the plugin, and Kotlin DSL, the preferred way to get the version automatically is to do
implementation(kotlin("stdlib-jdk8"))
m

mbonnin

08/08/2019, 6:34 PM
Yep, that's the thing that doesn't work
ERROR: Failed to resolve: org.jetbrains.kotlin:kotlin-stdlib-jdk8:
Affected Modules: app
The
kotlin()
shorthand just prepends "org.jetbrains.kotlin", it does not add version
s

Sergey Chelombitko

08/08/2019, 6:56 PM
@mbonnin are you using Kotlin JVM plugin or Kotlin Android plugin?
m

mbonnin

08/08/2019, 6:58 PM
id("kotlin-android")
Kotlin Android it is
s

Sergey Chelombitko

08/08/2019, 7:01 PM
Kotlin Android plugin doesn't allow to omit version of
kotlin-stdlib*
until 1.3.50
or any other libraries in
org.jetbrains.kotlin
group
m

mbonnin

08/08/2019, 7:03 PM
The this is it allows me to omit the version of
kotlin-stdlib
s

Sergey Chelombitko

08/08/2019, 7:04 PM
That's coincidence because there was simply no such feature in Kotlin Android plugin. I know this because I ported it from JVM plugin to Android plugin.
o

octylFractal

08/08/2019, 7:04 PM
kotlin-stdlib
may be an transitive dependency of another
kotlin-android
library, and therefore doesn't need a version. I don't recall exactly how gradle handles that case.
m

mbonnin

08/08/2019, 7:07 PM
Ah yes, good catch. It seems the kotlin-android-extensions plugin pulls
org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.3.41
and that in turns pull
kotlin-stdlib
So I can just remove
implementation("org.jetbrains.kotlin:kotlin-stdlib")
but if I need jdk8 I have to specify the version. It all makes sense, thanks!