Kotlin: Kotlin-script (.kts) cannot use regular code?
There is experimental support for maven imports in Kotlin scripts since 1.3.
Take a look at https://blog.jetbrains.com/kotlin/2018/09/kotlin-1-3-rc-is-here-migrate-your-coroutines/#scripting:
@file:Repository("https://jcenter.bintray.com")
@file:DependsOn("org.jetbrains.kotlinx:kotlinx-html-jvm:0.6.11")
import kotlinx.html.*
import kotlinx.html.stream.*
print(createHTML().html {
body {
h1 { +"Hello, World!" }
}
})
And here is the KEEP: https://github.com/Kotlin/KEEP/blob/master/proposals/scripting-support.md.
Alternative is using the Kotlin REPL instead.
I suggest to use holgerbrandl/kscript to manage dependencies of your script.
This is a bug in the Kotlin plugin: https://youtrack.jetbrains.com/issue/KT-11618