``` Line 15: kotlin("jvm") version "$kotlinVe...
# gradle
d
Copy code
Line 15:     kotlin("jvm") version "$kotlinVersion"
                                       ^ Unresolved reference: kotlinVersion`
p
buildscript { val kotlinVersion by extra = "1.3.40" dependencies { classpath("org.jetbrains.kotlinkotlin gradle plugin$kotlinVersion") } } val kotlinVersion : String by extra
buildscript section has to be compiled running your projects build scripts. So it does not know anything about your projects script elements. In example above you declare extra parameter in build script and retreive it in your project script, cause project script have access to parameters map in build script
d
that makes sense 👍
how does this work tho
val kotlinVersion : String by extra
does it get property by the same name from extra?
p
extra is delegate that takes name of property by your val name and type from your type
val nameOfProperty: TypeOfProperty by extra
in build script you have to register your proprty , so you write val nameOfProperty by extra = valueOfProperty
d
cool cool, is there a way to reference it in the plugins block? I have the same problem in groovy script, where I have to define version twice in extra propertiees and in plugins{} block
p
you can specify type but it will be undertood by compiler from you valueOfProerty type
no
plugins block live another live
their purpose to be as much determenistic as possible
d
thanks!
p
for your case you can do like this: plugins { kotlin("....") version "1.3.40" } val kotlinVersion = KotlinVersion.CURRENT.toString()
g
Also, you can just omit kotlin stdlib version
d
why is that btw?
g