https://kotlinlang.org logo
Title
d

Dias

07/19/2019, 9:46 AM
Line 15:     kotlin("jvm") version "$kotlinVersion"
                                       ^ Unresolved reference: kotlinVersion`
p

PHondogo

07/19/2019, 9:50 AM
buildscript { val kotlinVersion by extra = "1.3.40" dependencies { classpath("org.jetbrains.kotlin:kotlin-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

Dias

07/19/2019, 9:55 AM
that makes sense 👍
how does this work tho
val kotlinVersion : String by extra
does it get property by the same name from extra?
p

PHondogo

07/19/2019, 9:56 AM
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

Dias

07/19/2019, 9:57 AM
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

PHondogo

07/19/2019, 9:57 AM
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

Dias

07/19/2019, 10:01 AM
thanks!
p

PHondogo

07/19/2019, 10:05 AM
for your case you can do like this: plugins { kotlin("....") version "1.3.40" } val kotlinVersion = KotlinVersion.CURRENT.toString()
g

gildor

07/19/2019, 10:28 AM
Also, you can just omit kotlin stdlib version
d

Dias

07/19/2019, 12:24 PM
why is that btw?
g

gildor

07/19/2019, 12:57 PM