trick you used in Groovy, just with Kotlin syntax.
That is to initially define the variable, you use
extra
explicitly, so
val foo by extra("bar")
, in the root project
and just get it from the subproject to use it, so
val foo: String by project
But the question is whether you should do it.
In almost all cases using
ext
or
extra
is a work-around and one should feel dirty when using it.
Most often there is a better way, like for example adding a properly typed extension to the project instead.