【问题标题】:How can I load external dependencies using ki (Kotlin Interactive Shell)?How can I load external dependencies using ki (Kotlin Interactive Shell)?
【发布时间】:2022-12-19 09:43:07
【问题描述】:
I am using using Ki (Kotlin Language Interactive Shell) to run Kotlin interactively on the shell, and I came across the need to load a 3rd-party library so I can script something quick. For example, let's say I want to use turtle to run a simple ls command:
com.lordcodes.turtle.shellRun("ls")
How can I set my ki shell in a way that turtle becomes available?
【问题讨论】:
标签:
shell
kotlin
dependency-management
【解决方案1】:
You will need to use the :dependsOn command:
[0] :dependsOn com.lordcodes.turtle:turtle:0.8.0
[1] com.lordcodes.turtle.shellRun("ls")
Ki allows you to download dependencies in runtime using Maven coordinates.
You can see the source code here: org.jetbrains.kotlinx.ki.shell.plugins.DependsOnCommand