Skip to content

Instantly share code, notes, and snippets.

@purefn
Created October 9, 2015 04:27
Show Gist options
  • Save purefn/540bea3d15c954d7281f to your computer and use it in GitHub Desktop.
Save purefn/540bea3d15c954d7281f to your computer and use it in GitHub Desktop.
TaskKey[Unit]("cleanCompile") <<= {
import Step._
val go =
for {
_ <- doClean
_ <- doCompile
} yield ()
go.run
}
import sbt._
import Keys._
case class Step[A](run: Def.Initialize[Task[A]]) {
def map[B](f: A => B): Step[B] =
Step[B](Def.taskDyn {
Def.task { f(run.value) }
})
def flatMap[B](f: A => Step[B]): Step[B] =
Step[B](Def.taskDyn {
f(run.value).run
})
}
object Step {
val doClean = Step(Def.task(clean.value))
val doCompile = Step(Def.task(compile.in(Compile).value))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment