To have your property available in any build section (including the plugins
) you can map it as a system property using the systemProp
prefix in your gradle.properties
file, like so:
systemProp.kotlinVersion = 1.9.0
and access it anywhere in your build.gradle.kts
script(s), for example:
plugins {
val kotlinVersion: String by System.getProperties()
kotlin("android").version(kotlinVersion).apply(false)
}
For regular sections (e.g. dependencies
) you may omit the systemProp.
prefix and access the value specified in your gradle.properties
(e.g. myVersion = 1.2.3
) like so:
dependencies {
val myVersion: String by project
implementation("some.group:artifactId:$myVersion")
}