Skip to content

Instantly share code, notes, and snippets.

@leon
Last active Sep 3, 2016
Embed
What would you like to do?
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