diff --git a/main/Build.scala b/main/Build.scala index 03e063311..b7aeec170 100644 --- a/main/Build.scala +++ b/main/Build.scala @@ -337,11 +337,14 @@ object Load else key } def setDefining[T] = (key: ScopedKey[T], value: T) => value match { - case tk: Task[t] if !EvaluateTask.isDummy(tk) => Task(tk.info.set(EvaluateTask.taskDefinitionKey, key), tk.work).asInstanceOf[T] + case tk: Task[t] => setDefinitionKey(tk, key).asInstanceOf[T] + case ik: InputTask[t] => ik.mapTask( tk => setDefinitionKey(tk, key) ).asInstanceOf[T] case _ => value } ss.map(s => s mapReferenced mapSpecial(s.key) mapInit setDefining ) } + def setDefinitionKey[T](tk: Task[T], key: ScopedKey[_]): Task[T] = + if(EvaluateTask isDummy tk) tk else Task(tk.info.set(EvaluateTask.taskDefinitionKey, key), tk.work) def structureIndex(settings: Settings[Scope]): StructureIndex = new StructureIndex(Index.stringToKeyMap(settings), Index.taskToKeyMap(settings), KeyIndex(settings.allKeys( (s,k) => ScopedKey(s,k)))) diff --git a/main/Defaults.scala b/main/Defaults.scala index 7e0467307..904c7c973 100755 --- a/main/Defaults.scala +++ b/main/Defaults.scala @@ -72,7 +72,6 @@ object Defaults crossPaths :== true, generatedResources :== Nil, classpathTypes := Set("jar", "bundle"), -// shellPrompt :== (_ => "> "), aggregate :== Aggregation.Enabled, maxErrors :== 100, showTiming :== true, @@ -138,7 +137,7 @@ object Defaults definedSbtPlugins <<= discoverPlugins, inTask(run)(runnerSetting :: Nil).head, selectMainClass <<= discoveredMainClasses map selectRunMain, - mainClass in run :== selectMainClass, + mainClass in run :== selectMainClass in run, mainClass <<= discoveredMainClasses map selectPackageMain, run <<= runTask(fullClasspath, mainClass in run, runner in run), runMain <<= runMainTask(fullClasspath, runner in run), diff --git a/main/Structure.scala b/main/Structure.scala index dfa6c7785..358c91318 100644 --- a/main/Structure.scala +++ b/main/Structure.scala @@ -13,13 +13,22 @@ package sbt import java.io.File import java.net.URI -sealed trait InputTask[T] -private final class InputStatic[T](val parser: State => Parser[Task[T]]) extends InputTask[T] +sealed trait InputTask[T] { + def mapTask[S](f: Task[T] => Task[S]): InputTask[S] +} +private final class InputStatic[T](val parser: State => Parser[Task[T]]) extends InputTask[T] { + def mapTask[S](f: Task[T] => Task[S]) = new InputStatic(s => parser(s) map f) +} private sealed trait InputDynamic[T] extends InputTask[T] -{ +{ outer => type Result def parser: State => Parser[Result] def task: Task[T] + def mapTask[S](f: Task[T] => Task[S]) = new InputDynamic[S] { + type Result = outer.Result + def parser = outer.parser + def task = f(outer.task) + } } object InputTask { @@ -127,7 +136,7 @@ object Scoped protected final val scoped = ScopedKey(scope, key) final def :==(value: S): Setting[S] = :=(value) - final def :==(value: SettingKey[S]): Setting[S] = <<=(value(identity)) + final def :==(value: ScopedSetting[S]): Setting[S] = <<=(value(identity)) final def := (value: => S): Setting[S] = setting(scoped, Project.value(value)) final def ~= (f: S => S): Setting[S] = Project.update(scoped)(f) final def <<= (app: Initialize[S]): Setting[S] = setting(scoped, app) @@ -148,8 +157,8 @@ object Scoped def :==(value: S): ScS = :=(value) def ::=(value: Task[S]): ScS = Project.setting(scoped, Project.value( value )) def := (value: => S): ScS = ::=(task(value)) - def :== (v: TaskKey[S]): ScS = Project.setting(scoped, Project.app(ScopedKey(scope, v.key) :^: KNil)(_.head) ) - def :== (v: SettingKey[S]): ScS = <<=( v(const)) + def :== (v: ScopedTask[S]): ScS = Project.setting(scoped, Project.app(ScopedKey(v.scope, v.key) :^: KNil)(_.head) ) + def :== (v: ScopedSetting[S]): ScS = <<=( v(const)) def ~= (f: S => S): ScS = Project.update(scoped)( _ map f ) def <<= (app: App[S]): ScS = Project.setting(scoped, app) diff --git a/tasks/standard/System.scala b/tasks/standard/System.scala index 3bd859347..c9bcbe346 100644 --- a/tasks/standard/System.scala +++ b/tasks/standard/System.scala @@ -8,7 +8,7 @@ import Types._ import Task._ import Execute._ -object System +object Transform { def fromDummy[T](original: Task[T])(action: => T): Task[T] = Task(original.info, Pure(action _)) def fromDummyStrict[T](original: Task[T], value: T): Task[T] = fromDummy(original)( value) @@ -34,19 +34,13 @@ object System new (Task ~> Task) { def apply[T](in: Task[T]): Task[T] = map(in).getOrElse(in) } -} -object Transform -{ - final class Dummies[HL <: HList](val direct: KList[Task, HL]) def apply[HL <: HList, Key](dummies: KList[Task, HL], injected: HL) = { import System._ - Convert.taskToNode ∙ getOrId(dummyMap(dummies)(injected)) + taskToNode ∙ getOrId(dummyMap(dummies)(injected)) } -} -object Convert -{ + def taskToNode = new (Task ~> NodeT[Task]#Apply) { def apply[T](t: Task[T]): Node[Task, T] = t.work match { case Pure(eval) => toNode(KNil)( _ => Right(eval()) )