Title
j

janvladimirmostert

06/11/2020, 8:15 PM
is there a way to declare global variables in a build.gradle.kts? Trying to do something like this
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
object Version {
    const val kotlin = "1.4-M2"
}

plugins {
    kotlin("multiplatform").version(Version.kotlin)
d

Dariusz Kuc

06/11/2020, 8:55 PM
any reason why not to use
gradle.properties
for defining those?
👍 3
c

christophsturm

06/12/2020, 1:44 PM
variables defined in the build file are not available in the plugin block. you can define them in buildSrc or gradle.properties
d

Dariusz Kuc

06/12/2020, 2:01 PM
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

janvladimirmostert

06/13/2020, 9:20 AM
gradle.properties is certainly an option, thanks for the input!