Remember current URI + more tests. Review by @harrah

This commit is contained in:
Eugene Vigdorchik 2012-02-02 17:15:14 +04:00
parent 0dafd5ef26
commit 33ec1c419d
4 changed files with 29 additions and 5 deletions

View File

@ -534,8 +534,10 @@ object Load
}
def initialSession(structure: BuildStructure, rootEval: () => Eval, s: State): SessionSettings = {
val current = s get Keys.sessionSettings map (_.currentProject) getOrElse Map.empty
new SessionSettings(structure.root, projectMap(structure, current), structure.settings, Map.empty, Nil, rootEval)
val session = s get Keys.sessionSettings
val currentProject = session map (_.currentProject) getOrElse Map.empty
val currentBuild = session map (_.currentBuild) filter (uri => structure.units.keys exists (uri ==)) getOrElse structure.root
new SessionSettings(currentBuild, projectMap(structure, currentProject), structure.settings, Map.empty, Nil, rootEval)
}
def initialSession(structure: BuildStructure, rootEval: () => Eval): SessionSettings =
@ -546,8 +548,8 @@ object Load
val units = structure.units
val getRoot = getRootProject(units)
def project(uri: URI) = {
current get uri map {
p => if (structure allProjects uri map (_.id) contains p) p else getRoot(uri)
current get uri filter {
p => structure allProjects uri map (_.id) contains p
} getOrElse getRoot(uri)
}
units.keys.map(uri => (uri, project(uri))).toMap

View File

@ -0,0 +1,8 @@
import sbt._
object Build1 extends Build
{
lazy val root1 = Project("root1", file("root1")) settings(
TaskKey[Unit]("g") := {}
)
}

View File

@ -0,0 +1,6 @@
import sbt._
object Build2 extends Build
{
lazy val root2 = Project("root2", file("root2"))
}

View File

@ -2,4 +2,12 @@
> project sub
> f
> reload
> f
> f
$ copy-file changes/Build1.scala project/TestProject.scala
> reload
-> f
> g
# The current URI should be kept
$ copy-file changes/Build2.scala project/First.scala
> reload
> g