Marcelo Hernandez
03/22/2022, 9:50 PMbuildSrc with *.gradle.kts files in a multi-module Android project. I notice that with this change, the Kotlin Gradle DSL seems to be overriding the kotlin-stdlib to 1.5.31 for my actual project even though the project declares the following in the root build.gradle
dependencies {
…
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
The buildSrc/build.gradle.kts file is registering the kotlin-dsl plugin and declares the following in the dependencies block:
dependencies {
…
implementation(kotlin("gradle-plugin"))
}ephemient
03/22/2022, 9:57 PMephemient
03/22/2022, 10:00 PMkotlin-dsl }`) you should be using `plugins { embedded-kotlin }` or possibly plugins { kotlin("jvm") version embeddedKotlinVersion }ephemient
03/22/2022, 10:02 PMsettings.gradle
pluginManagement {
plugins {
resolutionStrategy {
eachPlugin {
if (requested.id.id.startsWith("org.jetbrains.kotlin.")) useVersion("1.6.10")
}
}
}
}
to get my projects to build with Kotlin 1.6.10, although there's other ways of achieving the same resultephemient
03/22/2022, 10:04 PMMarcelo Hernandez
03/22/2022, 10:27 PMkotlin-library.gradle.kts
plugins {
kotlin("jvm")
// additional plugins
}
kotlin-android-library.gradle.kts
plugins {
kotlin("android")
id("com.android.library")
// additional plugins
}
The goal is so that a pure JVM Kotlin module can simply apply
plugins {
id 'kotlin-library'
}
And an Android Kotlin library module can simply apply
plugins {
id 'kotlin-android-library'
}
Regarding the // additional plugins section, these would be linters such as Detekt and Spotless.Marcelo Hernandez
03/22/2022, 11:27 PMbuildSrc/build.gradle.kts, I had the following:
dependencies {
…
implementation(kotlin("gradle-plugin"))
}
I then changed it to
dependencies {
…
implementation(kotlin(module = "gradle-plugin", version = "1.6.10"))
}
And now my project is building with kotlin-stdlib 1.6.10. 🤷♂️