Extra properties in external Kotlin script

I have an external script customProperties.gradle.kts which defines a single value:

customProperties.gradle.kts

val myVersion by extra("3.1.0-RELEASE")

I’m then applying that script from build.gradle.kts and trying to print the value of myVersion:

build.gradle.kts

apply(from = "customProperties.gradle.kts")
println(myVersion)

But I get this error:

  Line 2: println(myVersion)
                  ^ Unresolved reference: myVersion

I have tried the same thing using the Groovy DSL successfully. Where am I going wrong?

Thanks in advance!