Idiomatically defining dynamic tasks in SBT 0.13?

前端 未结 1 888
深忆病人
深忆病人 2021-01-06 23:30

I\'m moving an SBT plugin from 0.12 over to 0.13. At various points in my plugin I schedule a dynamic set of tasks onto the SBT build graph.

1条回答
  •  借酒劲吻你
    2021-01-07 00:09

    You can use Def.taskDyn, which provides the new syntax for flatMap. The difference from Def.task is that the expected return type is a task Initialize[Task[T]] instead of just T. Translating your example,

    inParallel := parTask.value
    
    def parTask = Def.taskDyn {
       val t = times.value
       ordinals.value.map(o => ordinalTask(o, t)).joinWith(_.join)
    }
    
    def ordinalTask(o: String, t: Int) = Def.task {
       (0 until t).map(_ => o).mkString(",")
    }
    

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