Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run "package" before 'test"

Tags:

scala

sbt

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"?

like image 877
dips Avatar asked May 02 '12 11:05

dips


1 Answers

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
}
like image 186
Christian Avatar answered Oct 12 '22 12:10

Christian