J-P
05/13/2020, 1:15 AMalex j
05/13/2020, 5:29 AMJ-P
05/13/2020, 11:56 AMJ-P
05/13/2020, 2:54 PMalex j
05/13/2020, 3:05 PMilya.chernikov
05/14/2020, 9:23 AMkotlinc
one and the IntelliJ counterpart) do not support custom script definitions yet. But you can build your own relatively easily.
The easiest way will be to use JSR-223 with main-kts
, see the example here - https://github.com/JetBrains/kotlin/blob/1.3.70/libraries/tools/kotlin-main-kts-test/test/org/jetbrains/kotlin/mainKts/test/mainKtsJsr223Test.kt#L39
More advanced things are possible with the new REPL API which is introduced with 1.4 (starting from -M3, which is not published yet). Here you can have a look at the https://github.com/Kotlin/kotlin-jupyter for inspiration.
And if you'll run a REPL e.g. with main-kts
definition, the preconfiguration mode you described is easily achievable with @Import
annotation - you can configure things in a script and then simply @Import
it into the REPL.