SBT apply Task after Compile

前端 未结 1 475
长发绾君心
长发绾君心 2021-01-07 22:35

I am able to automatically execute a task before compilation with:

compile in Compile <<= (compile in Compile).dependsOn(myTask)

How

1条回答
  •  不要未来只要你来
    2021-01-07 23:15

    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.

    0 讨论(0)
提交回复
热议问题