mirror of
https://github.com/sbt/sbt.git
synced 2026-09-03 08:34:34 +02:00
Fixes #1478 - Append new sLog when reloading in set command.
* Migrate weak reference into logger class so we can test clearing it. * Ensure new state.log is propoagted into settings on `set` command. * Fix set test so that it ensures the sLog is relatively stable when reloading on set command.
This commit is contained in:
@@ -105,8 +105,8 @@ object LogManager {
|
||||
// construct a Logger that delegates to the global logger, but only holds a weak reference
|
||||
// this is an approximation to the ideal that would invalidate the delegate after loading completes
|
||||
private[this] def globalWrapper(s: State): Logger = {
|
||||
val ref = new java.lang.ref.WeakReference(s.globalLogging.full)
|
||||
new Logger {
|
||||
private[this] val ref = new java.lang.ref.WeakReference(s.globalLogging.full)
|
||||
private[this] def slog: Logger = Option(ref.get) getOrElse sys.error("Settings logger used after project was loaded.")
|
||||
|
||||
override val ansiCodesSupported = slog.ansiCodesSupported
|
||||
|
||||
@@ -227,7 +227,10 @@ object BuiltinCommands {
|
||||
def reapply(newSession: SessionSettings, structure: BuildStructure, s: State): State =
|
||||
{
|
||||
s.log.info("Reapplying settings...")
|
||||
val newStructure = Load.reapply(newSession.mergeSettings, structure)(Project.showContextKey(newSession, structure))
|
||||
// Here, for correct behavior, we also need to re-inject a settings logger, as we'll be re-evaluating settings.
|
||||
val loggerInject = LogManager.settingsLogger(s)
|
||||
val withLogger = newSession.appendRaw(loggerInject :: Nil)
|
||||
val newStructure = Load.reapply(withLogger.mergeSettings, structure)(Project.showContextKey(newSession, structure))
|
||||
Project.setProject(newSession, newStructure, s)
|
||||
}
|
||||
def set = Command(SetCommand, setBrief, setDetailed)(setParser) {
|
||||
|
||||
Reference in New Issue
Block a user