Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding task dependencies in .sbt file

In my build.sbt file I have two custom tasks:

TaskKey[Unit]("aaa") := {
  println("aaa")
} 

TaskKey[Unit]("bbb") := {
  println("bbb")
}

How do I add a dependency between them? For example, I want aaa to depend on bbb.

like image 875
dsg Avatar asked Mar 23 '26 19:03

dsg


1 Answers

From https://github.com/harrah/xsbt/wiki/Tasks

To depend on the side effect of some tasks without using their values and without doing additional work, use dependOn on a sequence of tasks. The defining task key (the part on the left side of <<=) must be of type Unit, since no value is returned.

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

To add dependencies to an existing task without using their values, call dependsOn on the task and provide the tasks to depend on. For example, the second task definition here modifies the original to require that string-task and sample-task run first:

intTask := 4

intTask <<= intTask.dependsOn(stringTask, sampleTask)
like image 159
Janx Avatar answered Mar 25 '26 07:03

Janx



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!