I\'d like to make an input task that proceed user input and generate bunch of subtasks to run. Here is the example:
import sbt._
import Keys._
import Def.Initial
Trial and error method gave me the answer but non a single bit of understanding. Here it is:
import sbt._
import Keys._
import Def.Initialize
import complete.DefaultParsers._
object TestBuild extends Build {
val sampleInput = inputKey[Seq[String]]("sample dynamic input task")
val sampleDynamic = taskKey[Seq[String]]("sample dynamic task")
override lazy val settings = super.settings ++ Seq(
sampleDynamic := Def.taskDyn {
val sources = Seq("ab", "csd", "efda")
sources.map(sampleTaskFor _).joinWith(_.join)
}.value,
sampleInput := Def.inputTaskDyn {
val sources = spaceDelimited("").parsed
sampleTaskAll(sources)
}.evaluated
)
private def sampleTaskFor(source : String) : Initialize[Task[String]] = Def.task {
source + " : " + source
}
private def sampleTaskAll(sources : Seq[String]) : Initialize[Task[Seq[String]]] = Def.taskDyn {
sources.map(sampleTaskFor _).joinWith(_.join)
}
}
For a reason I can not comprehend you should isolate creating multitask out of sequence of single tasks in a separate method.