Run custom task automatically before/after standard task

后端 未结 2 1209
南笙
南笙 2020-11-29 07:20

I often want to do some customization before one of the standard tasks are run. I realize I can make new tasks that executes existing tasks in the order I want, but I find t

2条回答
  •  抹茶落季
    2020-11-29 07:58

    Extending an existing task is documented the SBT documentation for Tasks (look at the section Modifying an Existing Task).

    Something like this:

    compile in Compile <<= (compile in Compile) map { _ => 
      // what you want to happen after compile goes here 
    }
    

    Actually, there is another way - define your task to depend on compile

    prepareAppTask := (whatever you want to do) dependsOn compile
    

    and then modify packageBin to depend on that:

    packageBin <<= packageBin dependsOn prepareAppTask
    

    (all of the above non-tested, but the general thrust should work, I hope).

提交回复
热议问题