on-load message customizable, more specific message for plugin projects

This commit is contained in:
Mark Harrah
2011-09-03 17:30:37 -04:00
parent 8938fc564e
commit 5420a48a87
5 changed files with 10 additions and 3 deletions
+1
View File
@@ -108,6 +108,7 @@ object Defaults extends BuildCommon
def projectCore: Seq[Setting[_]] = Seq( def projectCore: Seq[Setting[_]] = Seq(
name <<= thisProject(_.id), name <<= thisProject(_.id),
logManager <<= extraLoggers(LogManager.defaults), logManager <<= extraLoggers(LogManager.defaults),
onLoadMessage <<= onLoadMessage or (name, thisProjectRef)("Set current project to " + _ + " (in build " + _.build +")"),
runnerTask runnerTask
) )
def paths = Seq( def paths = Seq(
+1
View File
@@ -57,6 +57,7 @@ object GlobalPlugin
private[this] def log(s: State) = CommandSupport.logger(s) private[this] def log(s: State) = CommandSupport.logger(s)
val globalPluginSettings = inScope(Scope.GlobalScope in LocalRootProject)(Seq( val globalPluginSettings = inScope(Scope.GlobalScope in LocalRootProject)(Seq(
organization := "org.scala-tools.sbt", organization := "org.scala-tools.sbt",
onLoadMessage <<= Keys.baseDirectory("Loading global plugins from " + _),
name := "global-plugin", name := "global-plugin",
sbtPlugin := true, sbtPlugin := true,
version := "0.0" version := "0.0"
+1
View File
@@ -46,6 +46,7 @@ object Keys
val initialize = SettingKey[Unit]("initialize", "A convenience setting for performing side-effects during initialization.") 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 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 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.") 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 // https://issues.scala-lang.org/browse/SI-2915
+5 -1
View File
@@ -403,8 +403,12 @@ object Load
case Some(cp) => cp.data.fullClasspath case Some(cp) => cp.data.fullClasspath
case None => Nil 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 = 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 = def activateGlobalPlugin(config: LoadBuildConfiguration): LoadBuildConfiguration =
config.globalPlugin match config.globalPlugin match
{ {
+2 -2
View File
@@ -172,8 +172,8 @@ object Project extends Init[Scope] with ProjectExtra
val structure = Project.structure(s) val structure = Project.structure(s)
val ref = Project.current(s) val ref = Project.current(s)
val project = Load.getProject(structure.units, ref.build, ref.project) val project = Load.getProject(structure.units, ref.build, ref.project)
val label = Keys.name in ref get structure.data getOrElse ref.project val msg = Keys.onLoadMessage in ref get structure.data getOrElse ""
logger(s).info("Set current project to " + label + " (in build " + ref.build +")") if(!msg.isEmpty) logger(s).info(msg)
def get[T](k: SettingKey[T]): Option[T] = k in ref get structure.data 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 ; def commandsIn(axis: ResolvedReference) = commands in axis get structure.data toList ;