danbroooks danbroooks - 1 year ago 126
Scala Question

Unable to make reference to object in build.sbt, "error: not found: value hooks"

I'm trying to add gulp to my Play application, I have created a

object that should allow me to trigger the
command, but when I do
sbt run
I'm getting an error saying it could not find the object. Here is my hook:

package hooks

object Gulp extends CommandHook {

override def beforeStarted(): Unit = {

And then in

lazy val root = (project in file(".")).enablePlugins(PlayScala)

scalaVersion := "2.11.7"

scalacOptions ++= Seq("-deprecation")

libraryDependencies ++= Seq(
"junit" % "junit" % "4.10" % "test",
"org.reactivemongo" %% "play2-reactivemongo" % "0.11.14",
"com.typesafe.play" %% "play" % "2.5.0",
"com.typesafe.play" %% "play-netty-server" % "2.5.0"

PlayKeys.playRunHooks += hooks.Gulp()

But I get:

build.sbt:18: error: not found: value hooks
PlayKeys.playRunHooks += hooks.Gulp()

Answer Source

You have to create Gulp object in project/ directory like below:

import play.sbt.PlayRunHook
import sbt._

object Gulp {
  def apply(base: File): PlayRunHook = {

    object GulpProcess extends PlayRunHook {

      override def beforeStarted(): Unit = {
        Process("gulp", base).run


Then in your build.sbt:

PlayKeys.playRunHooks += Gulp(baseDirectory.value)

For more details check this guide.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download