Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to declare task dependency on tasks in 0.13?

Tags:

scala

sbt

In sbt 0.12, you could specify that one task depended upon another without actually using the output from the input tasks. So you were specifying purely an ordering on the tasks:

unitTask <<= Seq(stringTask, sampleTask).dependOn

There is no such example in the Tasks documentation for sbt 0.13. What's the new syntax for specifying said dependency?

like image 781
Alex Wilson Avatar asked Oct 10 '13 10:10

Alex Wilson


2 Answers

Use the standard syntax, but ignore the results of the tasks used:

unitTask := {
  val x = stringTask.value
  val y = sampleTask.value
  ()
}

Because of a bug in scalac, you have to use dummy names, otherwise you could just use val _ = ....

Also, I prefer the more explicit way above, but it is equivalent to this shorter version because the results aren't used:

unitTask := {
  stringTask.value
  sampleTask.value
}
like image 73
Mark Harrah Avatar answered Nov 02 '22 19:11

Mark Harrah


The official migration guide recommends that instead of:

a <<= a dependsOn b

define it as:

a := (a dependsOn b).value
like image 43
Todd Owen Avatar answered Nov 02 '22 21:11

Todd Owen