我有一个 Scala 编译器项目。一些测试用例依赖于生成的 jar 文件。
因此,我总是在运行“测试”任务之前手动运行“包”任务。
如何添加一个 SBT 任务来完成“测试”的工作,但将取决于“包”?
最佳答案
sbt 0.12:
将以下内容添加到您的项目设置中:
(test in Test) <<= (test in Test) dependsOn (Keys.`package` in Compile)
这会更改项目的测试任务。但您也可以定义自己的任务:
val myTestTask = TaskKey[Unit]("my-test-task", "runs package and then test")
然后将其添加到您的项目设置中:
myTestTask <<= (test in Test) dependsOn (Keys.`package` in Compile)
sbt 0.13:
将以下内容添加到您的项目设置中:
(test in Test) := {
(Keys.`package` in Compile).value
(test in Test).value
}
这会更改项目的测试任务。但您也可以定义自己的任务:
val myTestTask = taskKey[Unit]("runs package and then test")
然后将其添加到您的项目设置中:
myTestTask := {
(Keys.`package` in Compile).value
(test in Test).value
}
关于scala - 如何在 "package"之前运行 'test",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10412675/