我想定义一个 sbt 任务,它将启动 scala 控制台,并在类路径上使用项目的已编译类并执行一些初始命令。
我想像这样开始那个 REPL 会话
sbt session
这是我根据其他答案汇总的抱歉尝试,但是既不将项目的类放在类路径上,也不不执行初始命令:
// extend Test in hope to include compiled sources on the classpath.
val ReplSession = config("repl-session") extend(Test)
val root = project.in(file("."))
.configs(ReplSession)
.settings(inConfig(ReplSession)(initialCommands := """
| import foo._
| """.stripMargin))
// define task that starts the REPL session
lazy val session = TaskKey[Unit]("session")
session <<= Seq(
console in (root, ReplSession)
).dependOn