diff --git a/main/Defaults.scala b/main/Defaults.scala index cc69224e1..6990be471 100644 --- a/main/Defaults.scala +++ b/main/Defaults.scala @@ -108,6 +108,7 @@ object Defaults extends BuildCommon def projectCore: Seq[Setting[_]] = Seq( name <<= thisProject(_.id), logManager <<= extraLoggers(LogManager.defaults), + onLoadMessage <<= onLoadMessage or (name, thisProjectRef)("Set current project to " + _ + " (in build " + _.build +")"), runnerTask ) def paths = Seq( diff --git a/main/GlobalPlugin.scala b/main/GlobalPlugin.scala index c7557a0ec..92dcd1d76 100644 --- a/main/GlobalPlugin.scala +++ b/main/GlobalPlugin.scala @@ -57,6 +57,7 @@ object GlobalPlugin private[this] def log(s: State) = CommandSupport.logger(s) val globalPluginSettings = inScope(Scope.GlobalScope in LocalRootProject)(Seq( organization := "org.scala-tools.sbt", + onLoadMessage <<= Keys.baseDirectory("Loading global plugins from " + _), name := "global-plugin", sbtPlugin := true, version := "0.0" diff --git a/main/Keys.scala b/main/Keys.scala index db15d0df4..7cd85bfc4 100644 --- a/main/Keys.scala +++ b/main/Keys.scala @@ -46,6 +46,7 @@ object Keys val initialize = SettingKey[Unit]("initialize", "A convenience setting for performing side-effects during initialization.") val onLoad = SettingKey[State => State]("on-load", "Transformation to apply to the build state when the build is loaded.") val onUnload = SettingKey[State => State]("on-unload", "Transformation to apply to the build state when the build is unloaded.") + val onLoadMessage = SettingKey[String]("on-load-message", "Message to display when the project is loaded.") val onComplete = SettingKey[() => Unit]("on-complete", "Hook to run when task evaluation completes. The type of this setting is subject to change, pending the resolution of SI-2915.") // https://issues.scala-lang.org/browse/SI-2915 diff --git a/main/Load.scala b/main/Load.scala index b5eb79f69..75ecbb6f7 100644 --- a/main/Load.scala +++ b/main/Load.scala @@ -403,8 +403,12 @@ object Load case Some(cp) => cp.data.fullClasspath case None => Nil } + val autoPluginSettings: Seq[Setting[_]] = inScope(GlobalScope in LocalRootProject)(Seq( + Keys.sbtPlugin :== true, + Keys.onLoadMessage <<= Keys.baseDirectory("Loading project definition from " + _) + )) def enableSbtPlugin(config: LoadBuildConfiguration): LoadBuildConfiguration = - config.copy(injectSettings = config.injectSettings.copy(global = (Keys.sbtPlugin in Global in LocalRootProject :== true) +: config.injectSettings.global)) + config.copy(injectSettings = config.injectSettings.copy(global = autoPluginSettings ++ config.injectSettings.global)) def activateGlobalPlugin(config: LoadBuildConfiguration): LoadBuildConfiguration = config.globalPlugin match { diff --git a/main/Project.scala b/main/Project.scala index 91fed9692..80d4bf1d1 100644 --- a/main/Project.scala +++ b/main/Project.scala @@ -172,8 +172,8 @@ object Project extends Init[Scope] with ProjectExtra val structure = Project.structure(s) val ref = Project.current(s) val project = Load.getProject(structure.units, ref.build, ref.project) - val label = Keys.name in ref get structure.data getOrElse ref.project - logger(s).info("Set current project to " + label + " (in build " + ref.build +")") + val msg = Keys.onLoadMessage in ref get structure.data getOrElse "" + if(!msg.isEmpty) logger(s).info(msg) def get[T](k: SettingKey[T]): Option[T] = k in ref get structure.data def commandsIn(axis: ResolvedReference) = commands in axis get structure.data toList ;