how about using .gradle.kts there ? it would deduplicate the amount of repition for versions of dependencies and plugins
👍 1
m
Mike
10/30/2018, 2:00 AM
Sorry, but I don’t think it will.
The new
plugins
block does not support variables regardless of whether it’s Kotlin or Groovy. Has to do with internal optimizations of the build system.
The Gradle team is investigating how to achieve both the build speed, AND supporting variables in the plugins block.
n
Nikky
10/30/2018, 2:30 AM
it does when the variables are coming from buildSrc
Hmm, interesting. I wonder if Groovy does that too. Most likely it will.
Still feels like a lot of extra code to me just to avoid a bit of duplication.
Looking at @jasoet’s build.gradle more closely, I think the ext.kotlinVersion can be removed as it’s not used anywhere. That leaves the duplication in the plugins block for kotlin.jvm and kotlin.kapt. For me, that would be fine, but we all have our preferences.
n
Nikky
10/30/2018, 2:43 AM
at least once you have multiple modules having the versions and possibly dependency coordinates defined in buildSrc becomes a lot more viable
m
Mike
10/30/2018, 2:55 AM
Although not possible for plugins, for other dependencies, I tend to rely on dependency management. That way all the projects I’m working on use the same dependencies.
Different needs for different projects. But thank you for showing me an alternate way to identify versions in a build script.
j
jasoet
10/30/2018, 3:34 AM
I am waiting to Gradle 5, then after that I will move to kts.
kotlinVersion only used on buildscripts dependency and as far as I know we cannot use variable for defining plugin version yet