Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

move from TaskData to new system

  • Loading branch information...
commit 2a21a86f8cd99eefe2af3e8bceb71f3cde66a3cc 1 parent 5918c24
@harrah authored
View
22 main/Defaults.scala
@@ -194,7 +194,7 @@ object Defaults extends BuildCommon
compileIncSetup <<= compileIncSetupTask,
console <<= consoleTask,
consoleQuick <<= consoleQuickTask,
- discoveredMainClasses <<= TaskData.write(compile map discoverMainClasses) triggeredBy compile,
+ discoveredMainClasses <<= compile map discoverMainClasses storeAs discoveredMainClasses triggeredBy compile,
definedSbtPlugins <<= discoverPlugins,
inTask(run)(runnerTask :: Nil).head,
selectMainClass <<= discoveredMainClasses map selectRunMain,
@@ -257,7 +257,8 @@ object Defaults extends BuildCommon
loadedTestFrameworks <<= (testFrameworks, streams, testLoader) map { (frameworks, s, loader) =>
frameworks.flatMap(f => f.create(loader, s.log).map( x => (f,x)).toIterable).toMap
},
- definedTests <<= TaskData.writeRelated(detectTests)(_.map(_.name).distinct) triggeredBy compile,
+ definedTests <<= detectTests,
+ definedTestNames <<= definedTests map ( _.map(_.name).distinct) storeAs definedTestNames triggeredBy compile,
testListeners in GlobalScope :== Nil,
testOptions in GlobalScope :== Nil,
executeTests <<= (streams in test, loadedTestFrameworks, parallelExecution in test, testOptions in test, testLoader, definedTests, resolvedScoped, state) flatMap {
@@ -294,7 +295,7 @@ object Defaults extends BuildCommon
}
def testOnlyTask =
- InputTask( TaskData(definedTests)(testOnlyParser)(Nil) ) { result =>
+ InputTask( loadForParser(definedTestNames)( (s, i) => testOnlyParser(s, i getOrElse Nil) ) ) { result =>
(streams, loadedTestFrameworks, parallelExecution in testOnly, testOptions in testOnly, testLoader, definedTests, resolvedScoped, result, state) flatMap {
case (s, frameworks, par, opts, loader, discovered, scoped, (tests, frameworkOptions), st) =>
val filter = selectedFilter(tests)
@@ -405,7 +406,7 @@ object Defaults extends BuildCommon
def runMainTask(classpath: ScopedTask[Classpath], scalaRun: ScopedTask[ScalaRun]): Initialize[InputTask[Unit]] =
{
import DefaultParsers._
- InputTask( TaskData(discoveredMainClasses)(runMainParser)(Nil) ) { result =>
+ InputTask( loadForParser(discoveredMainClasses)( (s, names) => runMainParser(s, names getOrElse Nil) ) ) { result =>
(classpath, scalaRun, streams, result) map { case (cp, runner, s, (mainClass, args)) =>
toError(runner.run(mainClass, data(cp), args, s.log))
}
@@ -1133,7 +1134,18 @@ trait BuildCommon
def loadFromContext[T](task: ScopedTask[T], context: ScopedKey[_], s: State)(implicit f: sbinary.Format[T]): Option[T] =
SessionVar.load(SessionVar.resolveContext(task.scopedKey, context.scope, s), s)
- // these are for use in tasks
+ // intended for use in constructing InputTasks
+ def loadForParser[P,T](task: ScopedTask[T])(f: (State, Option[T]) => Parser[P])(implicit format: sbinary.Format[T]): Initialize[State => Parser[P]] =
+ loadForParserI(task)(Project value f)(format)
+ def loadForParserI[P,T](task: ScopedTask[T])(init: Initialize[(State, Option[T]) => Parser[P]])(implicit format: sbinary.Format[T]): Initialize[State => Parser[P]] =
+ (resolvedScoped, init)( (ctx, f) => (s: State) => f( s, loadFromContext(task, ctx, s)(format)) )
+
+ def getForParser[P,T](task: ScopedTask[T])(init: (State, Option[T]) => Parser[P]): Initialize[State => Parser[P]] =
+ getForParserI(task)(Project value init)
+ def getForParserI[P,T](task: ScopedTask[T])(init: Initialize[(State, Option[T]) => Parser[P]]): Initialize[State => Parser[P]] =
+ (resolvedScoped, init)( (ctx, f) => (s: State) => f(s, getFromContext(task, ctx, s)) )
+
+ // these are for use for constructing Tasks
def loadPrevious[T](task: ScopedTask[T])(implicit f: sbinary.Format[T]): Initialize[Task[Option[T]]] =
(state, resolvedScoped) map { (s, ctx) => loadFromContext(task, ctx, s)(f) }
View
1  main/Keys.scala
@@ -181,6 +181,7 @@ object Keys
val testLoader = TaskKey[ClassLoader]("test-loader", "Provides the class loader used for testing.")
val loadedTestFrameworks = TaskKey[Map[TestFramework,Framework]]("loaded-test-frameworks", "Loads Framework definitions from the test loader.")
val definedTests = TaskKey[Seq[TestDefinition]]("defined-tests", "Provides the list of defined tests.")
+ val definedTestNames = TaskKey[Seq[String]]("defined-test-names", "Provides the set of defined test names.")
val executeTests = TaskKey[Tests.Output]("execute-tests", "Executes all tests, producing a report.")
val test = TaskKey[Unit]("test", "Executes all tests.")
val testOnly = InputKey[Unit]("test-only", "Executes the tests provided as arguments or all tests if no arguments are provided.")
View
6 main/Project.scala
@@ -358,6 +358,8 @@ trait ProjectExtra
import sbinary.{Format, Operations}
object SessionVar
{
+ val DefaultDataID = "data"
+
// these are required because of inference+manifest limitations
final case class Key[T](key: ScopedKey[Task[T]])
final case class Map(map: IMap[Key, Id]) {
@@ -374,7 +376,7 @@ object SessionVar
def persist[T](key: ScopedKey[Task[T]], state: State, value: T)(implicit f: sbinary.Format[T]): Unit =
Project.structure(state).streams.use(key)( s =>
- Operations.write(s.binary(TaskData.DefaultDataID), value)(f)
+ Operations.write(s.binary(DefaultDataID), value)(f)
)
def get[T](key: ScopedKey[Task[T]], state: State): Option[T] = orEmpty(state get sessionVars) get key
@@ -398,7 +400,7 @@ object SessionVar
def read[T](key: ScopedKey[Task[T]], state: State)(implicit f: Format[T]): Option[T] =
Project.structure(state).streams.use(key) { s =>
- try { Some(Operations.read(s.readBinary(key, TaskData.DefaultDataID))) }
+ try { Some(Operations.read(s.readBinary(key, DefaultDataID))) }
catch { case e: Exception => None }
}
View
1  main/TaskData.scala
@@ -11,6 +11,7 @@ package sbt
import sbinary.{Format, Operations}
+@deprecated("Superseded by task state system.", "0.11.1")
object TaskData
{
val DefaultDataID = "data"
Please sign in to comment.
Something went wrong with that request. Please try again.