From a6cd3742aae5fc3ececcb508f7e1fa0fbe29e2a7 Mon Sep 17 00:00:00 2001 From: Rory Douglas Date: Wed, 8 Oct 2014 18:00:44 -0400 Subject: [PATCH 1/2] Updated to use override of projectSettings This made the plugin work for me on Ubuntu with sbt 0.13.6. Also updated a few dependencies to latest version. --- build.sbt | 6 +++--- project/build.properties | 2 +- src/main/scala/GrowlingTests.scala | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build.sbt b/build.sbt index 0f350fe..2de3c04 100644 --- a/build.sbt +++ b/build.sbt @@ -5,15 +5,15 @@ name := "sbt-growl-plugin" organization := "me.lessis" version <<= sbtVersion(v => - if (v.startsWith("0.11") || v.startsWith("0.12") || v.startsWith("0.13")) "0.1.3" + if (v.startsWith("0.11") || v.startsWith("0.12") || v.startsWith("0.13")) "0.1.4-SNAPSHOT" else error("unsupported sbt version %s" format v) ) scalacOptions ++= Seq("-feature", "-deprecation") -sbtVersion in Global := "0.13.0-RC1" +sbtVersion in Global := "0.13.6" -scalaVersion in Global := "2.10.2" +scalaVersion in Global := "2.10.4" resolvers += Opts.resolver.sonatypeReleases diff --git a/project/build.properties b/project/build.properties index f069b10..df58110 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.12.4 \ No newline at end of file +sbt.version=0.13.6 \ No newline at end of file diff --git a/src/main/scala/GrowlingTests.scala b/src/main/scala/GrowlingTests.scala index 3579834..dcc52d5 100644 --- a/src/main/scala/GrowlingTests.scala +++ b/src/main/scala/GrowlingTests.scala @@ -2,7 +2,7 @@ package growl import sbt._ import Keys._ -import sbt.Project.Initialize +import sbt.Def.Initialize object GrowlingTests extends sbt.Plugin { import GrowlKeys._ @@ -16,9 +16,9 @@ object GrowlingTests extends sbt.Plugin { val growler = SettingKey[Growler]("growler", "Interface used to growl test results at users. RRRRRRRRR!") } - val Growl = config("growl") + val Growl = config("growl") extend(Test) -// override val settings = super.settings ++ growlSettings + override lazy val projectSettings = growlSettings private def growlingTestListenerTask: Def.Initialize[sbt.Task[sbt.TestReportListener]] = (groupFormatter in Growl, exceptionFormatter in Growl, aggregateFormatter in Growl, growler in Growl, streams) map { From 6ef78c056d75e0b3c87fe76d145596867b4c47fa Mon Sep 17 00:00:00 2001 From: Daniel Spiewak Date: Wed, 10 Dec 2014 13:59:08 -0700 Subject: [PATCH 2/2] Implemented support for Notification Center --- src/main/scala/Growler.scala | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/main/scala/Growler.scala b/src/main/scala/Growler.scala index 0a7965c..a1d72c2 100644 --- a/src/main/scala/Growler.scala +++ b/src/main/scala/Growler.scala @@ -11,6 +11,12 @@ trait Growler { object Growler { def apply(): Growler = { + def isNotificationCenterFriendly = try { + Process("which terminal-notifier").!! matches ".*terminal-notifier\\s+" + } catch { + case e: Exception => false + } + def isLibNotifyBinFriendly = try { Process("which notify-send").!! matches ".*notify-send\\s+" } catch { @@ -25,7 +31,8 @@ object Growler { // TODO - Is this enough or too strong? def isMac = System.getProperty("os.name").toLowerCase().indexOf("mac") >= 0 - if(isMac) new MacGrowler + if(isMac && isNotificationCenterFriendly) new NotificationCenterGrowler + else if(isMac) new MacGrowler else if(isLibNotifyBinFriendly) new LibNotifyBinGrowler else if(isGrowlNotifyFriendly) new GrowlNotifyGrowler else new NullGrowler @@ -37,11 +44,24 @@ final class MacGrowler extends Growler { val img = msg.imagePath.getOrElse("") val base = meow.Growl title(msg.title) identifier(msg.id.getOrElse(msg.title)) message(msg.message) val rich = if(img.isEmpty) base else base.image(img) - (if(msg.sticky) rich.sticky() else rich).meow + (if(msg.sticky) rich.sticky() else rich).meow } override def toString = "growl" } +final class NotificationCenterGrowler extends Growler { + override def notify(msg: GrowlResultFormat): Unit = { + val args = Seq( + "-appIcon", msg.imagePath.getOrElse(""), + "-title", msg.title, + "-message", msg.message, + "-activate", "com.apple.Terminal") // TODO some weirdos still use iTerm + val sender = Process("terminal-notifier" +: args) + sender.! + } + override def toString = "terminal-notifier" +} + final class NullGrowler extends Growler { override def notify(msg: GrowlResultFormat): Unit = () override def toString = ""