Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
14
Help us understand the problem. What is going on with this article?
@suin

PlayFramework 2.3でactivator run時にgulpを起動する

More than 5 years have passed since last update.

PlayFramework2.3でactivator runしたときにgulpも起動する方法です。

元ネタはPlay Framework で開発用Webサーバと同時に grunt/gulp を起動する - はこべブログ ♨ですが、こちらの記事の方法では、Playの2.3からplay.Project.playScalaSettingsが無くなったので、うまく動きませんでした。

いろいろ調べてみたら、build.sbtでimport play.PlayImport.PlayKeys.playRunHooksしたら動きました。

build.sbt
name := """new-ui"""

version := "1.0-SNAPSHOT"

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

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
  jdbc,
  anorm,
  cache,
  ws,
  "jp.t2v" %% "play2-auth"      % "0.13.2",
  "jp.t2v" %% "play2-auth-test" % "0.13.2" % "test"
)

import play.PlayImport.PlayKeys.playRunHooks

playRunHooks += RunSubProcess("gulp watch")

project/RunSubProcess.scalaを作っておきます。

project/RunSubProcess.scala
import sbt._

import play.PlayRunHook

object RunSubProcess {
  def apply(command: String): PlayRunHook = {

    object RunSubProcessHook extends PlayRunHook {

      var process: Option[Process] = None

      override def beforeStarted(): Unit = {
        process = Some(Process(command).run)
      }

      override def afterStopped(): Unit = {
        process.map(p => p.destroy())
        process = None
      }
    }

    RunSubProcessHook
  }
}
14
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
suin
Qiita 4位/TypeScript入門書執筆中/TypeScripterのための座談会「YYTypeScript」主催/『実践ドメイン駆動設計』書籍邦訳レビュア/分報Slack考案/YYPHP主催/CodeIQマガジン執筆/株式会社クラフトマンソフトウェア創設/Web自動テスト「ShouldBee」の開発/TypeScript/DDD/OOP
craftsman_software
「インフラの心配は、もうおしまい」 インフラ運用を自動化し、手作業を限りなくゼロにする会社

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
14
Help us understand the problem. What is going on with this article?