Extra properties in external Kotlin script

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


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:


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

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!