is there a way to declare global variables in a bu...
# gradle
j
is there a way to declare global variables in a build.gradle.kts? Trying to do something like this
Copy code
val kotlinVersion: String = "1.4-M2"
// fun Project.kotlinVersion(): String = "1.4-M2"

plugins {
   kotlin("multiplatform").version(kotlinVersion)
this doesn't show any red lines in the IDE, but neither does it compile, i doesn't know what Version is
Copy code
object Version {
    const val kotlin = "1.4-M2"
}

plugins {
    kotlin("multiplatform").version(Version.kotlin)
d
any reason why not to use
gradle.properties
for defining those?
👍 3
c
variables defined in the build file are not available in the plugin block. you can define them in buildSrc or gradle.properties
d
ah yeah I think that part might be confusing concrete example - we ended up defining all properties in
gradle.properties
and then defining plugin versions in
settings.gradle.kts
under plugin management section (https://github.com/ExpediaGroup/graphql-kotlin/blob/master/settings.gradle.kts#L1, i.e. you can read those
by settings
) so we just reference the plugins in build file. All other properties are read in
build.gradle.kts
through
by project
j
gradle.properties is certainly an option, thanks for the input!
2586 Views