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

View File

@ -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(

View File

@ -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"

View File

@ -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

View File

@ -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
{

View File

@ -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 ;