Execute task after compilation
I need a myTask task to execute after the compilation task completes. I tried several things I found on this forum:
- using dependOn β only works if "sbt myTask" is explicitly called at the sbt prompt. But I need myTask to execute automatically whenever compilation is done.
- with triggeredBy - > myTask is never called
Working with the other way works like a charm, although that's not what I want. I mean:
(compile at compile) <<= (compile at compile) depends on myTask
forces myTask to be executed first and then the compilation task is performed. But I need myTask to execute after compilation is complete.
Any idea?
Many thanks.
+3
source to share
1 answer
Here is one way to change the compilation task for the call anotherTask
. Add to your build.sbt
next.
lazy val anotherTask = taskKey[Unit]("another task")
anotherTask := println("hello")
compile in Compile := {
val compileAnalysis = (compile in Compile).value
anotherTask.value
compileAnalysis
}
+2
source to share