2

具有格式的 Kotlin 脚本可以轻松地通过和注释*.main.kts拉取依赖项。@file:Repository@file:DependsOn

但我尝试了与 REPL 类似的方法:

kotlinc-jvm -cp <InstallationPath>/lib/kotlin-main-kts.jar (手动指定 jar 只是因为默认情况下它没有加载)

import kotlin.script.experimental.dependencies.*  // just because they aren't imported automatically

@file:Repository("https://dl.bintray.com/<repo-path>")
@file:DependsOn("<dependency-notation>")

com.from.dependency.Class()

它抛出:error: unresolved reference: from

我们可以在 REPL 中使用依赖项吗?如果是,如何?我真的不想手动指定罐子,因为如果我这样做,我还需要手动下载它的所有依赖项,这是一个糟糕的解决方案。

我想应该有一些像pipKotlin REPL 这样的工具,如果我们真的不想用 gradle 设置一个完整的项目来进行一些测试和东西,这可能会使这个过程更容易,更好。

4

0 回答 0