Adding new task dependencies to built-in SBT tasks?

前端 未结 4 2001
耶瑟儿~
耶瑟儿~ 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:11

    Update: See arussell84's answer for a modern way to do this

    You should be able to do it like this:

    in a .sbt file:

    compile <<= (compile in Compile) dependsOn jruby
    

    Where jruby is a task key that you've defined in a project/something.scala file:

    val jruby = TaskKey[Unit]("jruby", "run a jruby file")
    

    Also, this isn't part of your question but you can just call regular Scala code:

    compile <<= (compile in Compile) map { result =>
      println("in compile, something")
      result
    }
    

提交回复
热议问题