我们可以在执行 sbt 命令时运行 scala 脚本吗?



每当我们使用像"sbt compile"或"sbt assembly"这样的sbt命令时,我都想运行一个脚本。

有没有办法做到这一点?

将步骤附加到任务的过程类似于以下内容:

compile <<= (compile in Compile) map {result =>
  // whatever you want to do after compile here.
  result
}

如果要定义运行脚本的自定义Command,请在生成中定义类似于

def myCommand = Command.command("myCommand") { state =>
  s"<relative path to script here>" !; state
}

然后,您将myCommand添加到要myCommand运行的每个任务中。

最新更新