Is there a way to only have `kotlin_version` defin...
# gradle
z
Is there a way to only have
kotlin_version
defined in one place when using gradle kts and buildSrc? I’ve tried having an object inside of buildSrc, but I can’t reference that in buildSrc’s
build.gradle.kts
plugin block itself. I’ve tried putting it into gradle.properties and reading it out, which requried a workaround I found on github, but then didn’t work outside of the
buildSrc
module. This seems like something there should be a good accepted solution for
t
z
so, that’s just for the build itself, right? ie, my app can still use 1.3.50?
t
That version comes from gradle-kotlin-dsl plugin. Mine is pretty recent (
1.3.41
), but yes, that's the Kotlin version you use in your project.
z
I’ll look into it, thanks
t
One workaround would be define
val kotlinVersion = "1.3.50"
and add that to ext, then you can use the variable in your buildscript and the ext in the other modules.
z
I feel like I’ve tried that and it still bails in the
plugin
block
t
That's right... Let me take a look.
https://github.com/gradle/gradle/issues/1697
The Kotlin DSL does not yet support replacement of properties in the version argument.
This is the best I was able to come with
z
Interesting. That’s what I’d tried to do, but couldn’t get access to the
Versions
object within the
plugins { }
block at runtime
t
Did you add the
build.gradle.kts
to
buildSrc
root?
Copy code
plugins {
    `kotlin-dsl`
}

repositories {
    mavenCentral()
}
z
yeah, that was the plugin block that was having problems
t
Can't think of anything but gradle version then
It is compiling here.
z
well ok, now it’s working. I took the
kotlin("jvm")
plugin out from `buildSrc`’s
build.gradle.kts
file and now things are working
🎉 1