I am able to automatically execute a task before compilation with:
compile in Compile <<= (compile in Compile).dependsOn(myTask)
How
In general, there is some task that depends on your task.
If compile
is being used to mean "compile and set things up for Grunt", then create a prepareGrunt
task that depends on compile
and myTask
and run that instead.
If myTask
should run before the project's classes and resources are used by something else, then make it a dependency of exportedProducts
. Tasks like run
and test
and tasks in dependent projects will get the exported classpath entries from that task.
The danger in "run sometime after compile" is that myTask
won't be run before the task that actually needs it. There is the triggeredBy
method on Initialize[Task[T]]
, but it is easily abused and should only be used when the output of the task is known to be used only after all tasks execute.