mirror of https://github.com/sbt/sbt.git
Provide implicits in consoleProject to add .eval to task and setting keys. Fixes #815.
This commit is contained in:
parent
4b8f0f3f94
commit
a4d0a0cb5a
|
|
@ -10,7 +10,9 @@ object ConsoleProject
|
|||
def apply(state: State, extra: String, cleanupCommands: String = "", options: Seq[String] = Nil)(implicit log: Logger)
|
||||
{
|
||||
val extracted = Project extract state
|
||||
val bindings = ("currentState" -> state) :: ("extracted" -> extracted ) :: Nil
|
||||
val cpImports = new Imports(extracted, state)
|
||||
|
||||
val bindings = ("currentState" -> state) :: ("extracted" -> extracted ) :: ("cpHelpers" -> cpImports) :: Nil
|
||||
val unit = extracted.currentUnit
|
||||
val compiler = Compiler.compilers(ClasspathOptions.repl)(state.configuration, log).scalac
|
||||
val imports = BuildUtil.getImports(unit.unit) ++ BuildUtil.importAll(bindings.map(_._1))
|
||||
|
|
@ -18,4 +20,12 @@ object ConsoleProject
|
|||
val initCommands = importString + extra
|
||||
(new Console(compiler))(unit.classpath, options, initCommands, cleanupCommands)(Some(unit.loader), bindings)
|
||||
}
|
||||
/** Conveniences for consoleProject that shouldn't normally be used for builds. */
|
||||
final class Imports private[sbt](extracted: Extracted, state: State)
|
||||
{
|
||||
import extracted._
|
||||
implicit def taskKeyEvaluate[T](t: TaskKey[T]): Evaluate[T] = new Evaluate(runTask(t, state)._2)
|
||||
implicit def settingKeyEvaluate[T](s: SettingKey[T]): Evaluate[T] = new Evaluate(get(s))
|
||||
}
|
||||
final class Evaluate[T] private[sbt](val eval: T)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue