mirror of https://github.com/sbt/sbt.git
Merge pull request #348 from vigdorchik/wip_keep_project_on_reload
keep project on reload
This commit is contained in:
commit
3efcc07b93
|
|
@ -533,13 +533,26 @@ object Load
|
|||
}
|
||||
}
|
||||
|
||||
def initialSession(structure: BuildStructure, rootEval: () => Eval, s: State): SessionSettings = {
|
||||
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 =
|
||||
new SessionSettings(structure.root, rootProjectMap(structure.units), structure.settings, Map.empty, Nil, rootEval)
|
||||
new SessionSettings(structure.root, projectMap(structure, Map.empty), structure.settings, Map.empty, Nil, rootEval)
|
||||
|
||||
def rootProjectMap(units: Map[URI, LoadedBuildUnit]): Map[URI, String] =
|
||||
def projectMap(structure: BuildStructure, current: Map[URI, String]): Map[URI, String] =
|
||||
{
|
||||
val units = structure.units
|
||||
val getRoot = getRootProject(units)
|
||||
units.keys.map(uri => (uri, getRoot(uri))).toMap
|
||||
def project(uri: URI) = {
|
||||
current get uri filter {
|
||||
p => structure allProjects uri map (_.id) contains p
|
||||
} getOrElse getRoot(uri)
|
||||
}
|
||||
units.keys.map(uri => (uri, project(uri))).toMap
|
||||
}
|
||||
|
||||
def defaultEvalOptions: Seq[String] = Nil
|
||||
|
|
|
|||
|
|
@ -335,8 +335,8 @@ object BuiltinCommands
|
|||
val (s, base) = Project.loadAction(SessionVar.clear(s0), action)
|
||||
IO.createDirectory(base)
|
||||
val (eval, structure) = Load.defaultLoad(s, base, logger(s))
|
||||
val session = Load.initialSession(structure, eval)
|
||||
val session = Load.initialSession(structure, eval, s0)
|
||||
SessionSettings.checkSession(session, s)
|
||||
Project.setProject(session, structure, s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
import sbt._
|
||||
|
||||
object Build1 extends Build
|
||||
{
|
||||
lazy val root1 = Project("root1", file("root1")) settings(
|
||||
TaskKey[Unit]("g") := {}
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
import sbt._
|
||||
|
||||
object Build2 extends Build
|
||||
{
|
||||
lazy val root2 = Project("root2", file("root2"))
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
import sbt._
|
||||
|
||||
object TestBuild extends Build
|
||||
{
|
||||
lazy val root = Project("root", file("."), aggregate = Seq(sub)) settings(
|
||||
TaskKey[Unit]("f") := error("f")
|
||||
)
|
||||
lazy val sub = Project("sub", file("sub")) settings(
|
||||
TaskKey[Unit]("f") := {}
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
-> f
|
||||
> project sub
|
||||
> f
|
||||
> reload
|
||||
> 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
|
||||
Loading…
Reference in New Issue