I have an alternative way of completing an existing expensive task, though I don't know until runtime if I'll do it that way. (For example, a file cache.)
How do I do this?
For example, packageBin:
packageBin in Compile := Def.taskDyn {
if (canDoItMyWay) {
doItMyWayTask
} else {
Defaults.packageTask
}
}.value
This doesn't work if it executes the latter path:
$ sbt packageBin
[trace] Stack trace suppressed: run last compile:packageBin for the full output.
[error] (util-2_10/compile:packageBin) sbt.Init$RuntimeUndefined: References to undefined settings at runtime.