Since SBT 0.13.13 this is deprecated (<<=
is deprecated):
compile in Compile <<= (compile in Compile).dependsOn(apiDoc)
So the only way to do I found is this:
compile in Compile := {
apiDoc.value
(compile in Compile).value
}
But now I have a warning about a useless expression apiDoc.value
.
But this is not useless!
I can't find any documentation about what is the new way to do.
I haven't found docs for this, but you can create a dependsOn
like:
compile.in(Compile) := compile.dependsOn(apiDoc).value
Note that if you're doing this for an InputTask
, you'll need to use evaluated
instead of value
:
myInputTask := myInputTask.dependsOn(apiDoc).evaluated
I've struggled with the problem of depending tasks and it all became clear after I read this page: http://www.beyondthelines.net/computing/understanding-sbt/
TLD;DR: to make a task dependent on another inside a task definition, you have to use Def.sequential
(examples from the page):
lazy val A = taskKey[Unit]("Task A")
A in Global := { println("Task A") }
lazy val B = taskKey[Unit]("Task B")
B in Global := { println("Task B") }
lazy val C = taskKey[Unit]("Task C")
C := Def.sequential(A, B).value
So for your case, it would be:
compile in Compile := Def.sequential(apiDoc, compile in Compile).value
Or, if you use the new sbt syntax and have different scoping:
ThisBuild / Compile / compile := Def.sequential(apiDoc, Compile / compile).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