From 1c1be9a597a94bd2f61de3948d6cae939cd14e6b Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Thu, 27 Apr 2017 13:26:17 +0100 Subject: [PATCH] Introduce suppressSbtShellNotification This requires moving the notification to after LoadProject, so much later in time, sadly.. Refs #3091 --- main/src/main/scala/sbt/Keys.scala | 1 + main/src/main/scala/sbt/Main.scala | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/main/src/main/scala/sbt/Keys.scala b/main/src/main/scala/sbt/Keys.scala index fd75b43ba..439896c12 100644 --- a/main/src/main/scala/sbt/Keys.scala +++ b/main/src/main/scala/sbt/Keys.scala @@ -64,6 +64,7 @@ object Keys { val shellPrompt = SettingKey(BasicKeys.shellPrompt) val analysis = AttributeKey[inc.Analysis]("analysis", "Analysis of compilation, including dependencies and generated outputs.", DSetting) val watch = SettingKey(BasicKeys.watch) + val suppressSbtShellNotification = SettingKey[Boolean]("suppressSbtShellNotification", """True to suppress the "Executing in batch mode.." message.""", CSetting) val pollInterval = SettingKey[Int]("poll-interval", "Interval between checks for modified sources by the continuous execution command.", BMinusSetting) val watchSources = TaskKey[Seq[File]]("watch-sources", "Defines the sources in this project for continuous execution to watch for changes.", BMinusSetting) val watchTransitiveSources = TaskKey[Seq[File]]("watch-transitive-sources", "Defines the sources in all projects for continuous execution to watch.", CSetting) diff --git a/main/src/main/scala/sbt/Main.scala b/main/src/main/scala/sbt/Main.scala index ad42f485b..43f5de17f 100644 --- a/main/src/main/scala/sbt/Main.scala +++ b/main/src/main/scala/sbt/Main.scala @@ -99,7 +99,7 @@ object BuiltinCommands { ifLast, multi, shell, continuous, eval, alias, append, last, lastGrep, export, boot, nop, call, exit, early, initialize, act) ++ compatCommands def DefaultBootCommands: Seq[String] = - WriteSbtVersion :: NotifyUsersAboutShell :: LoadProject :: s"$IfLast $Shell" :: Nil + WriteSbtVersion :: LoadProject :: NotifyUsersAboutShell :: s"$IfLast $Shell" :: Nil def boot = Command.make(BootCommand)(bootParser) @@ -576,9 +576,11 @@ object BuiltinCommands { (state.remainingCommands contains Shell) || (state.remainingCommands.lastOption exists (_ == s"$IfLast $Shell")) - private def notifyUsersAboutShell(state: State) = - if (isInteractive && !intendsToInvokeShell(state) && !intendsToInvokeNew(state)) + private def notifyUsersAboutShell(state: State): Unit = { + val suppress = Project extract state getOpt Keys.suppressSbtShellNotification getOrElse false + if (!suppress && isInteractive && !intendsToInvokeShell(state) && !intendsToInvokeNew(state)) state.log info "Executing in batch mode. For better performance use sbt's shell; hit [ENTER] to do so now" + } private def NotifyUsersAboutShell = "notify-users-about-shell"