I have a scala compiler project. Some of the test cases depend on the generated jar file. Therefore, I always manually run the "package" task before running the "test" task.
How can I add a SBT task that will do the job of "test" but will depend on "package"?
sbt 0.12:
Add the following to your project settings:
(test in Test) <<= (test in Test) dependsOn (Keys.`package` in Compile)
This changes the test task for your project. But you can also define your own task:
val myTestTask = TaskKey[Unit]("my-test-task", "runs package and then test")
And then add this to your project settings:
myTestTask <<= (test in Test) dependsOn (Keys.`package` in Compile)
sbt 0.13:
Add the following to your project settings:
(test in Test) := {
(Keys.`package` in Compile).value
(test in Test).value
}
This changes the test task for your project. But you can also define your own task:
val myTestTask = taskKey[Unit]("runs package and then test")
And then add this to your project settings:
myTestTask := {
(Keys.`package` in Compile).value
(test in Test).value
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With