Adding new task dependencies to built-in SBT tasks?

前端 未结 4 2000
耶瑟儿~
耶瑟儿~ 2021-02-01 03:43

Is it possible to override or modify built-in SBT tasks (like compile) to depend on custom tasks in my own Build.scala? Overriding e.g. \"compile\" directly is not possible sinc

4条回答
  •  北恋
    北恋 (楼主)
    2021-02-01 04:21

    Reply to self: http://code.google.com/p/simple-build-tool/wiki/ProjectDefinitionExamples#Insert_Task_Dependency tells the answer:

    If you are using older 0.7.x SBT versions you can do this:

    import sbt._
    class SampleProject(info: ProjectInfo) extends DefaultProject(info) {
      lazy val printAction = task { print("Testing...") }
      override def compileAction = super.compileAction dependsOn(printAction)
    }
    

提交回复
热议问题