I am using Android Studio 4.0 and I added buildSrc module in a multi-module project to manage dependency versions. Inside buildSrc i have Dependencies object and Version object to use kotlin-dsl in the build.gradle.kts, The problem it's I can't access to Constants object from gradle.kts and I have 2 versions of com.android.tools.build:gradle:4.0.0 and I need this dependency for my custom plugins, How I can have only one version of the buildtools?
//Dependencies.kt
object PluginDependencies {
const val buildTools = "com.android.tools.build:gradle:${Versions.buildTools}"
}
//Versions.kt
object Versions {
const val buildTools = "4.0.0"
}
I have this in my build.gradle.kts
plugins {
`kotlin-dsl`
}
gradlePlugin {
plugins {
register("CustomPlugin") {
id = "customPlugin"
implementationClass = "CustomPlugin"
}
}
}
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
// this cuase a compile error -> implementation("com.android.tools.build:gradle:${constants.Versions.buildTools}")
implementation("com.android.tools.build:gradle:4.0.0")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72")
/* Depend on the default Gradle API's since we want to build a custom plugin */
implementation(gradleApi())
implementation(localGroovy())
}