I was told that it is generally recommended to add kotlin-bom
as a dependency to all projects to make sure all Kotlin components are version-aligned. My gradle code looks like this:
plugins {
kotlin("multiplatform") version "1.4.0" apply false
}
allprojects {
repositories {
jcenter()
}
dependencies {
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
}
}
This fails with an “Unresolved reference: implementation” error. From what I gather, this is because the Kotlin plugin isn’t actually applied here, and implementation
is part of the Kotlin Gradle DSL.
(I don’t apply that plugin because in the root Gradle script I don’t actually declare any kotlin targets, so I’d get “Please initialize at least one Kotlin target” errors. I only want to pin the kotlin-multiplatform version to 1.4.0 in the root script, that’s all.)
But now I am wondering how to apply kotlin-bom
. I could add the implementation
line for each platform (in commonMain, commonTest, linuxMain, linuxTest etc.) but there has to be a better way that does not require such a repetition, right?