Add task dependencies in the .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 to aaa

depend on bbb

.

+3


source to share


2 answers


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

To depend on the side effect of some tasks without using their values โ€‹โ€‹and without additional work, use dependOn for the task sequence. The defining task key (the part to the left 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 the dependOn function on the task and provide the dependent tasks. For example, the second task definition here modifies the original by requiring the task-string and sample-task to be executed first:

intTask := 4

intTask <<= intTask.dependsOn(stringTask, sampleTask)

      

+2


source


val aaa = TaskKey[Unit]("aaa", "First")
val bbb = TaskKey[Unit]("bbb", "Second")

bbb := { println("bbb") }
aaa := bbb map { _ => println("aaa") }

      



0


source







All Articles