Skip to content

Instantly share code, notes, and snippets.

@leon
Last active September 3, 2016 02:23
Show Gist options
  • Save leon/6669138 to your computer and use it in GitHub Desktop.
Save leon/6669138 to your computer and use it in GitHub Desktop.
Playframework 2.2 Grunt Runner
name := "GruntApp"
version := "1.0-SNAPSHOT"
libraryDependencies ++= Seq(
jdbc,
anorm,
cache
)
play.Project.playScalaSettings
playRunHooks <+= baseDirectory.map(base => Grunt(base / "app" / "assets"))
import sbt._
import Keys._
import java.net._
import java.io.File
import play.PlayRunHook
/*
Grunt runner should be in project directory to be picked up by sbt
*/
object Grunt {
def apply(base: File): PlayRunHook = {
object GruntProcess extends PlayRunHook {
var process: Option[Process] = None
override def beforeStarted(): Unit = {
Process("grunt dist", base).run
}
override def afterStarted(addr: InetSocketAddress): Unit = {
process = Some(Process("grunt run", base).run)
}
override def afterStopped(): Unit = {
process.map(p => p.destroy())
process = None
}
}
GruntProcess
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment