diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-01-23 01:58:48 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-01-23 01:58:48 -0800 |
commit | 3052a900570d45b2b17e51d8f83b5fdddf6ad290 (patch) | |
tree | fe1d14cdb63fd947f15666472a196e72976218d5 /core/src | |
parent | 0ea8b3d10ae7500426b174a33ef70d03d474ecc4 (diff) | |
download | mill-3052a900570d45b2b17e51d8f83b5fdddf6ad290.tar.gz mill-3052a900570d45b2b17e51d8f83b5fdddf6ad290.tar.bz2 mill-3052a900570d45b2b17e51d8f83b5fdddf6ad290.zip |
Small cleanup of duplicate `Task` code into `NamedTaskImpl`
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/mill/define/Task.scala | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/core/src/mill/define/Task.scala b/core/src/mill/define/Task.scala index bafabd01..a6d90922 100644 --- a/core/src/mill/define/Task.scala +++ b/core/src/mill/define/Task.scala @@ -242,29 +242,25 @@ object Caller { q"new _root_.mill.define.Caller[${weakTypeOf[T]}](this)" } } +abstract class NamedTaskImpl[+T](ctx0: mill.define.Ctx, t: Task[T]) extends NamedTask[T]{ + def evaluate(args: mill.util.Ctx) = args[T](0) + val ctx = ctx0.copy(segments = ctx0.segments ++ Seq(ctx0.segment)) + val inputs = Seq(t) +} class TargetImpl[+T](t: Task[T], ctx0: mill.define.Ctx, - val readWrite: RW[_]) extends Target[T] { - val ctx = ctx0.copy(segments = ctx0.segments ++ Seq(ctx0.segment)) - val inputs = Seq(t) - def evaluate(args: mill.util.Ctx) = args[T](0) + val readWrite: RW[_]) extends NamedTaskImpl[T](ctx0, t) with Target[T] { } class Command[+T](t: Task[T], ctx0: mill.define.Ctx, - val writer: W[_]) extends NamedTask[T] { - val ctx = ctx0.copy(segments = ctx0.segments ++ Seq(ctx0.segment)) - val inputs = Seq(t) - def evaluate(args: mill.util.Ctx) = args[T](0) + val writer: W[_]) extends NamedTaskImpl[T](ctx0, t) { override def asCommand = Some(this) } -class Worker[+T](t: Task[T], - ctx0: mill.define.Ctx) extends NamedTask[T] { - val ctx = ctx0.copy(segments = ctx0.segments ++ Seq(ctx0.segment)) - val inputs = Seq(t) - def evaluate(args: mill.util.Ctx) = args[T](0) +class Worker[+T](t: Task[T], ctx0: mill.define.Ctx) extends NamedTaskImpl[T](ctx0, t) { + override def asWorker = Some(this) } class Persistent[+T](t: Task[T], @@ -277,18 +273,12 @@ class Persistent[+T](t: Task[T], } class Input[T](t: Task[T], ctx0: mill.define.Ctx, - val readWrite: RW[_]) extends Target[T]{ - val ctx = ctx0.copy(segments = ctx0.segments ++ Seq(ctx0.segment)) - val inputs = Seq(t) - def evaluate(args: mill.util.Ctx) = args[T](0) + val readWrite: RW[_]) extends NamedTaskImpl[T](ctx0, t) with Target[T]{ override def sideHash = util.Random.nextInt() } object Task { - - - class Task0[T](t: T) extends Task[T]{ lazy val t0 = t val inputs = Nil |