mirror of https://github.com/sbt/sbt.git
Fixes #856 - Store ++ scala version changes on session.
* Ensure the ++ command stores its changes on the sbt session.
* Make sure `session clear-all` will clear out ++ changes
* Validate that `set` command doesn't undo `++` changes
Note: There is some autogenerated Setting[_] delegate optimisation
work that could be done in the future.
This commit is contained in:
parent
7f1786924f
commit
cc7546b1eb
|
|
@ -41,6 +41,12 @@ object Cross {
|
|||
case _ => ("", arg)
|
||||
}
|
||||
val home = IO.resolve(x.currentProject.base, new File(homePath))
|
||||
// Basic Algorithm.
|
||||
// 1. First we figure out what the new scala instances should be, create settings for them.
|
||||
// 2. Find any non-overridden scalaVersion setting in the whole build and force it to delegate
|
||||
// to the new global settings.
|
||||
// 3. Append these to the session, so that the session is up-to-date and
|
||||
// things like set/session clear, etc. work.
|
||||
val (add, exclude) =
|
||||
if (home.exists) {
|
||||
val instance = ScalaInstance(home)(state.classLoaderCache.apply _)
|
||||
|
|
@ -63,10 +69,18 @@ object Cross {
|
|||
)
|
||||
(settings, excludeKeys(Set(scalaVersion.key, scalaHome.key)))
|
||||
}
|
||||
val cleared = session.mergeSettings.filterNot(exclude)
|
||||
val newStructure = Load.reapply(add ++ cleared, structure)
|
||||
Project.setProject(session, newStructure, command :: state)
|
||||
// TODO - Track delegates and avoid regenerating.
|
||||
val delegates: Seq[Setting[_]] = session.mergeSettings collect {
|
||||
case x if exclude(x) => delegateToGlobal(x.key)
|
||||
}
|
||||
val fixedSession = session.appendRaw(add ++ delegates)
|
||||
BuiltinCommands.reapply(fixedSession, structure, state)
|
||||
}
|
||||
|
||||
// Creates a delegate for a scoped key that pulls the setting from the global scope.
|
||||
private[this] def delegateToGlobal[T](key: ScopedKey[T]): Setting[_] =
|
||||
SettingKey[T](key.key) in key.scope := (SettingKey[T](key.key) in GlobalScope).value
|
||||
|
||||
@deprecated("No longer used.", "0.13.0")
|
||||
def crossExclude(s: Setting[_]): Boolean = excludeKeys(Set(scalaVersion.key, scalaHome.key))(s)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
> check 2.7.7 2.9.1 2.9.0-1
|
||||
> ++ 2.8.2
|
||||
> check 2.8.2 2.8.2 2.8.1
|
||||
> ++ 2.10.4
|
||||
> set resolvers ++= Nil
|
||||
> check 2.10.4 2.10.4 2.10.4
|
||||
> session clear-all
|
||||
> check 2.7.7 2.9.1 2.9.0-1
|
||||
Loading…
Reference in New Issue