mirror of https://github.com/sbt/sbt.git
put remaining keys in Keys
This commit is contained in:
parent
5a67998490
commit
dfb0a9ec8c
|
|
@ -6,8 +6,7 @@ package sbt
|
|||
import CommandSupport.logger
|
||||
import Project.ScopedKey
|
||||
import Load.BuildStructure
|
||||
import EvaluateTask.parseResult
|
||||
import Keys.{aggregate, showSuccess, showTiming, timingFormat}
|
||||
import Keys.{aggregate, parseResult, showSuccess, showTiming, timingFormat}
|
||||
import sbt.complete.Parser
|
||||
import java.net.URI
|
||||
import Parser._
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ package sbt
|
|||
import complete.DefaultParsers.validID
|
||||
import Compiler.{Compilers,Inputs}
|
||||
import Project.{inScope, ScopedKey, ScopeLocal, Setting}
|
||||
import Keys.{appConfiguration, baseDirectory, configuration, streams, thisProject, thisProjectRef}
|
||||
import Keys.{appConfiguration, baseDirectory, configuration, streams, Streams, TaskStreams, thisProject, thisProjectRef}
|
||||
import Keys.{dummyState, dummyStreamsManager, isDummy, parseResult, resolvedScoped, streamsManager, taskDefinitionKey}
|
||||
import TypeFunctions.{Endo,Id}
|
||||
import tools.nsc.reporters.ConsoleReporter
|
||||
import Build.{analyzed, data}
|
||||
|
|
@ -110,29 +111,14 @@ object EvaluateTask
|
|||
import Project.display
|
||||
import std.{TaskExtra,Transform}
|
||||
import TaskExtra._
|
||||
import BuildStreams.{Streams, TaskStreams}
|
||||
import Keys.state
|
||||
|
||||
val SystemProcessors = Runtime.getRuntime.availableProcessors
|
||||
|
||||
val isDummyTask = AttributeKey[Boolean]("is-dummy-task")
|
||||
val taskDefinitionKey = AttributeKey[ScopedKey[_]]("task-definition-key")
|
||||
val (state, dummyState) = dummy[State]("state")
|
||||
val (streamsManager, dummyStreamsManager) = dummy[Streams]("streams-manager")
|
||||
val resolvedScoped = SettingKey[ScopedKey[_]]("resolved-scoped")
|
||||
private[sbt] val parseResult: TaskKey[_] = TaskKey("$parse-result")
|
||||
|
||||
def injectSettings: Seq[Project.Setting[_]] = Seq(
|
||||
(state in GlobalScope) ::= dummyState,
|
||||
(streamsManager in GlobalScope) ::= dummyStreamsManager
|
||||
)
|
||||
|
||||
def dummy[T](name: String): (TaskKey[T], Task[T]) = (TaskKey[T](name), dummyTask(name))
|
||||
def dummyTask[T](name: String): Task[T] =
|
||||
{
|
||||
val base: Task[T] = task( error("Dummy task '" + name + "' did not get converted to a full task.") ) named name
|
||||
base.copy(info = base.info.set(isDummyTask, true))
|
||||
}
|
||||
def isDummy(t: Task[_]): Boolean = t.info.attributes.get(isDummyTask) getOrElse false
|
||||
|
||||
def evalPluginDef(log: Logger)(pluginDef: BuildStructure, state: State): Seq[Attributed[File]] =
|
||||
{
|
||||
|
|
@ -332,7 +318,7 @@ object Load
|
|||
// additionally, set the task axis to the defining key if it is not set
|
||||
def finalTransforms(ss: Seq[Setting[_]]): Seq[Setting[_]] =
|
||||
{
|
||||
import EvaluateTask.{parseResult, resolvedScoped}
|
||||
import Keys.{parseResult, resolvedScoped}
|
||||
def isSpecial(key: AttributeKey[_]) = key == streams.key || key == resolvedScoped.key || key == parseResult.key
|
||||
def mapSpecial(to: ScopedKey[_]) = new (ScopedKey ~> ScopedKey){ def apply[T](key: ScopedKey[T]) =
|
||||
if(isSpecial(key.key))
|
||||
|
|
@ -351,7 +337,7 @@ object Load
|
|||
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)
|
||||
if(isDummy(tk)) tk else Task(tk.info.set(Keys.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))))
|
||||
|
|
@ -683,8 +669,6 @@ object BuildStreams
|
|||
import Project.display
|
||||
import std.{TaskExtra,Transform}
|
||||
|
||||
type Streams = std.Streams[ScopedKey[_]]
|
||||
type TaskStreams = std.TaskStreams[ScopedKey[_]]
|
||||
val GlobalPath = "$global"
|
||||
val BuildUnitPath = "$build"
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ package sbt
|
|||
import compiler.Discovery
|
||||
import Project.{inConfig, Initialize, inScope, inTask, ScopedKey, Setting}
|
||||
import Configurations.{Compile => CompileConf, Test => TestConf}
|
||||
import EvaluateTask.resolvedScoped
|
||||
import complete._
|
||||
import std.TaskExtra._
|
||||
|
||||
|
|
@ -81,7 +80,7 @@ object Defaults
|
|||
showSuccess :== true,
|
||||
commands :== Nil,
|
||||
retrieveManaged :== false,
|
||||
settings <<= EvaluateTask.state map { state => Project.structure(state).data }
|
||||
settings <<= state map { state => Project.structure(state).data }
|
||||
))
|
||||
def projectCore: Seq[Setting[_]] = Seq(
|
||||
name <<= thisProject(_.id),
|
||||
|
|
@ -157,7 +156,7 @@ object Defaults
|
|||
watch <<= watchSetting
|
||||
)
|
||||
|
||||
def inAllConfigurations[T](key: ScopedTask[T]): Initialize[Task[Seq[T]]] = (EvaluateTask.state, thisProjectRef) flatMap { (state, ref) =>
|
||||
def inAllConfigurations[T](key: ScopedTask[T]): Initialize[Task[Seq[T]]] = (state, thisProjectRef) flatMap { (state, ref) =>
|
||||
val structure = Project structure state
|
||||
val configurations = Project.getProject(ref, structure).toList.flatMap(_.configurations)
|
||||
configurations.flatMap { conf =>
|
||||
|
|
@ -165,7 +164,7 @@ object Defaults
|
|||
} join
|
||||
}
|
||||
def watchTransitiveSourcesTask: Initialize[Task[Seq[File]]] =
|
||||
(EvaluateTask.state, thisProjectRef) flatMap { (s, base) =>
|
||||
(state, thisProjectRef) flatMap { (s, base) =>
|
||||
inAllDependencies(base, watchSources.setting, Project structure s).join.map(_.flatten)
|
||||
}
|
||||
def watchSourcesTask: Initialize[Task[Seq[File]]] = Seq(sources, resources).map(inAllConfigurations).join { _.join.map(_.flatten.flatten) }
|
||||
|
|
@ -323,7 +322,7 @@ object Defaults
|
|||
def discoverMainClasses(analysis: inc.Analysis): Seq[String] =
|
||||
Discovery.applications(Tests.allDefs(analysis)) collect { case (definition, discovered) if(discovered.hasMain) => definition.name }
|
||||
|
||||
def consoleProjectTask = (EvaluateTask.state, streams, initialCommands in consoleProject) map { (state, s, extra) => Console.sbt(state, extra)(s.log); println() }
|
||||
def consoleProjectTask = (state, streams, initialCommands in consoleProject) map { (state, s, extra) => Console.sbt(state, extra)(s.log); println() }
|
||||
def consoleTask: Initialize[Task[Unit]] = consoleTask(fullClasspath, console)
|
||||
def consoleQuickTask = consoleTask(externalDependencyClasspath, consoleQuick)
|
||||
def consoleTask(classpath: TaskKey[Classpath], task: TaskKey[_]): Initialize[Task[Unit]] = (compilers, classpath, scalacOptions in task, initialCommands in task, streams) map {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
package sbt
|
||||
|
||||
import java.io.File
|
||||
import EvaluateTask.resolvedScoped
|
||||
import Project.ScopedKey
|
||||
import complete._
|
||||
import inc.Analysis
|
||||
import std.TaskExtra._
|
||||
|
|
@ -207,5 +207,22 @@ object Keys
|
|||
|
||||
// special
|
||||
val settings = TaskKey[Settings[Scope]]("settings")
|
||||
val streams = TaskKey[BuildStreams.TaskStreams]("streams")
|
||||
val streams = TaskKey[TaskStreams]("streams")
|
||||
val isDummyTask = AttributeKey[Boolean]("is-dummy-task")
|
||||
val taskDefinitionKey = AttributeKey[ScopedKey[_]]("task-definition-key")
|
||||
val (state, dummyState) = dummy[State]("state")
|
||||
val (streamsManager, dummyStreamsManager) = dummy[Streams]("streams-manager")
|
||||
val resolvedScoped = SettingKey[ScopedKey[_]]("resolved-scoped")
|
||||
private[sbt] val parseResult: TaskKey[_] = TaskKey("$parse-result")
|
||||
|
||||
type Streams = std.Streams[ScopedKey[_]]
|
||||
type TaskStreams = std.TaskStreams[ScopedKey[_]]
|
||||
|
||||
def dummy[T](name: String): (TaskKey[T], Task[T]) = (TaskKey[T](name), dummyTask(name))
|
||||
def dummyTask[T](name: String): Task[T] =
|
||||
{
|
||||
val base: Task[T] = task( error("Dummy task '" + name + "' did not get converted to a full task.") ) named name
|
||||
base.copy(info = base.info.set(isDummyTask, true))
|
||||
}
|
||||
def isDummy(t: Task[_]): Boolean = t.info.attributes.get(isDummyTask) getOrElse false
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
package sbt
|
||||
|
||||
import java.util.regex.Pattern
|
||||
import BuildStreams.{Streams, TaskStreams}
|
||||
import Keys.{Streams, TaskStreams}
|
||||
import Project.ScopedKey
|
||||
|
||||
object Output
|
||||
|
|
|
|||
|
|
@ -47,10 +47,10 @@ object InputTask
|
|||
// This interface allows the Parser to be constructed using other Settings, but not Tasks (which is desired).
|
||||
// The action can be constructed using Settings and Tasks and with the parse result injected into a Task.
|
||||
// This is the ugly part, requiring hooks in injectStreams and Act to handle the dummy task for the parse result.
|
||||
// However, this is results in a minimal interface to the full capabilities of an InputTask
|
||||
// However, this is results in a minimal interface to the full capabilities of an InputTask for users
|
||||
def apply[I,T](p: Initialize[State => Parser[I]])(action: TaskKey[I] => Initialize[Task[T]]): Initialize[InputTask[T]] =
|
||||
{
|
||||
val key = EvaluateTask.parseResult.asInstanceOf[TaskKey[I]]
|
||||
val key = Keys.parseResult.asInstanceOf[TaskKey[I]]
|
||||
p.zipWith(action(key)) { (parserF, act) =>
|
||||
new InputDynamic[T]
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue