当前位置: 首页>>代码示例>>Scala>>正文


Scala PlayRunHook类代码示例

本文整理汇总了Scala中play.sbt.PlayRunHook的典型用法代码示例。如果您正苦于以下问题:Scala PlayRunHook类的具体用法?Scala PlayRunHook怎么用?Scala PlayRunHook使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PlayRunHook类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。

示例1: EmberRunner

//设置package包名称以及导入依赖的类
import java.io.File
import java.net.InetSocketAddress

import play.sbt.PlayRunHook
import sbt._

object EmberRunner {
  def apply(logger: Logger,
            baseDir: File,
            port: Int = 4200): PlayRunHook = {

    object EmberRunHook extends PlayRunHook {
      var watchProcess: Option[Process] = None

      override def beforeStarted(): Unit = {
        if (baseDir.exists()) {
          logger.info("Executing npm install")
          val npm = Process(Seq("npm", "install"), baseDir).lines
          npm.foreach(logger.info(_))

          logger.info("Executing bower install")
          val bower = Process(Seq("bower", "install"), baseDir).lines
          bower.foreach(logger.info(_))
        } else {
          logger.info(s"Skipping npm and bower install. UI application directory ${baseDir.getAbsolutePath} not found.")
        }
      }

      override def afterStarted(addr: InetSocketAddress): Unit = {
        addr.getAddress.getHostAddress
        val url = s"http://localhost:${addr.getPort}"
        if (baseDir.exists()) {
          logger.info(s"Starting ember server in development mode. Setting proxy to $url")
          watchProcess = Some(Process(Seq("ember", "serve", "--proxy", url, "--port", port.toString), baseDir).run(logger))
        } else {
          logger.info(s"Skipping ember server start. UI application directory ${baseDir.getAbsolutePath} not found.")
        }
      }

      override def afterStopped(): Unit = {
        logger.info("Attempting to stop ember server")
        watchProcess.foreach(_.destroy())
        watchProcess = None
      }
    }
    EmberRunHook
  }
} 
开发者ID:dipayanb,项目名称:play-ember-seed,代码行数:49,代码来源:EmberRunner.scala

示例2: Webpack

//设置package包名称以及导入依赖的类
import java.net.InetSocketAddress

import play.sbt.PlayRunHook
import sbt._

object Webpack {
  def apply(base: File): PlayRunHook = {
    object WebpackHook extends PlayRunHook {
      var process: Option[Process] = None

      override def beforeStarted() = {
        process = Option(
          Process("webpack", base).run()
        )
      }

      override def afterStarted(addr: InetSocketAddress) = {
        process = Option(
          Process("webpack --watch", base).run()
        )
      }

      override def afterStopped() = {
        process.foreach(_.destroy())
        process = None
      }
    }

    WebpackHook
  }
} 
开发者ID:dehora,项目名称:outland-deck,代码行数:32,代码来源:Webpack.scala

示例3: HTMLValidation

//设置package包名称以及导入依赖的类
import play.sbt.PlayRunHook
import sbt._


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

    object HTMLValidationProcess extends PlayRunHook {

      var validationRun: Option[Process] = None

      override def beforeStarted(): Unit = {
        val env = "dev"
        validationRun = Some(validationProcess(base, env).run)
      }

      override def afterStopped(): Unit = {
        // Stop when play run stops
       validationRun.map(p => p.destroy())
       validationRun = None
      }

    }

    HTMLValidationProcess
  }

  def command(base: File) = Command.command("w3c") { state =>
    validationProcess(base) !;
    state
  }

  def validationProcess(base: File, args: String*) = {
    // have to use Process rather than fork because of NPE with get class loader in vnu tool
    val log = ConsoleLogger()
    log.info("Starting HTML Validation task...")
    Process("java" :: "-jar" :: s"${base.getAbsolutePath}/project/tools/vnu.jar" :: "--skip-non-html" :: "--verbose" :: "--format" :: "text" :: "--html" :: "--errors-only" :: s"${base.getAbsolutePath}/target/html" :: ">" :: "out.txt" :: args.toList, base)
  }
} 
开发者ID:hmrc,项目名称:paac-frontend,代码行数:40,代码来源:HTMLValidation.scala

示例4: Grunt

//设置package包名称以及导入依赖的类
import play.sbt.PlayRunHook
import sbt._


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

    object GruntProcess extends PlayRunHook {

      var gruntRun: Option[Process] = None

      override def beforeStarted(): Unit = {
        val env = "dev"
        val log = ConsoleLogger()
        log.info(s"run npm install... $env")
        npmProcess(base, "install").!

        log.info("Starting default Grunt task..")
        gruntRun = Some(gruntProcess(base, env, "--verbose").run())
      }

      override def afterStopped(): Unit = {
        // Stop grunt when play run stops
       gruntRun.map(p => p.destroy())
       gruntRun = None
      }

    }

    GruntProcess
  }

  def gruntCommand(base: File) = Command.args("grunt", "<grunt-command>") { (state, args) =>
    gruntProcess(base, args:_*) !;
    state
  }
  def gruntProcess(base: File, args: String*) = Process("node" :: "node_modules/.bin/grunt" :: args.toList, base)
  def npmProcess(base: File, args: String*) = Process("npm" :: args.toList, base)

} 
开发者ID:hmrc,项目名称:paac-frontend,代码行数:41,代码来源:Grunt.scala

示例5: Webpack

//设置package包名称以及导入依赖的类
import java.net.InetSocketAddress

import play.sbt.PlayRunHook
import sbt._

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

    object WebpackProcess extends PlayRunHook {

      var process: Option[Process] = None

      override def beforeStarted(): Unit = {
        Process("npm install").!
      }

      override def afterStarted(addr: InetSocketAddress): Unit = {
        process = Some(Process("./node_modules/.bin/webpack --progress -d --watch", base).run)
      }

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

    WebpackProcess
  }
} 
开发者ID:toolsplus,项目名称:atlassian-connect-play-seed,代码行数:30,代码来源:Webpack.scala

示例6: Grunt

//设置package包名称以及导入依赖的类
import play.sbt.PlayRunHook
import sbt._
 
import java.net.InetSocketAddress
 
object Grunt {
  def apply(base: File): PlayRunHook = {
 
    object GruntProcess extends PlayRunHook {

      var process: Option[Process] = None

      override def beforeStarted(): Unit = {
        Process("grunt --force", base).run
      }
      override def afterStarted(addr: InetSocketAddress): Unit = {
        process = Some(Process("grunt --force watch", base).run)
      }
      override def afterStopped(): Unit = {
        process.map(p => p.destroy())
        process = None
      }

    }

    GruntProcess
  }
} 
开发者ID:hmrc,项目名称:pertax-frontend,代码行数:29,代码来源:Grunt.scala

示例7: WebpackServer

//设置package包名称以及导入依赖的类
import java.io.File
import java.net.InetSocketAddress

import play.sbt.PlayRunHook
import sbt._

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

    object WebpackServerScript extends PlayRunHook {

      var process: Option[Process] = None // This is really ugly, how can I do this functionally?

      override def afterStarted(address: InetSocketAddress): Unit = {
        process = if (System.getProperty("os.name").toUpperCase().indexOf("WIN") >= 0)
          Option(Process("cmd /c npm start", base).run)
        else
          Option(Process("npm start", base).run)
      }

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

    WebpackServerScript
  }
} 
开发者ID:epot,项目名称:play-silhouette-angular-typescript.g8,代码行数:30,代码来源:WebpackServer.scala

示例8: Gulp

//设置package包名称以及导入依赖的类
import java.net.InetSocketAddress

import sbt._
import play.sbt.PlayRunHook



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

    object GulpProcess extends PlayRunHook {

      var gulpRun: Option[Process] = None

      override def beforeStarted(): Unit = {
        val log = ConsoleLogger()
        log.info("run npm install...")
        npmProcess(base, "install").!

        log.info("Starting default Gulp task..")
        gulpRun = Some(gulpProcess(base, "default").run())
      }

      override def afterStopped(): Unit = {
        // Stop gulp when play run stops
        gulpRun.foreach(p => p.destroy())
        gulpRun = None
      }

    }

    GulpProcess
  }

  def gulpCommand(base: File) = Command.args("gulp", "<gulp-command>") { (state, args) =>
    gulpProcess(base, args:_*) !;
    state
  }

  def gulpProcess(base: File, args: String*): ProcessBuilder = {
    if (sys.props("os.name").toLowerCase contains "windows") {
      Process("cmd" :: "/c" :: "node_modules\\.bin\\gulp.cmd" :: args.toList, base)
    }
    else {
      Process("node" :: "node_modules/.bin/gulp" :: args.toList, base)
    }
  }

  def npmProcess(base: File, args: String*): ProcessBuilder = {
    if (sys.props("os.name").toLowerCase contains "windows") {
      Process("cmd" :: "/c" :: "npm" :: args.toList, base)
    }
    else {
      Process("npm" :: args.toList, base)
    }
  }
} 
开发者ID:hmrc,项目名称:voa-property-linking-frontend,代码行数:58,代码来源:Gulp.scala

示例9: UIBuild

//设置package包名称以及导入依赖的类
import java.net.InetSocketAddress

import play.sbt.PlayRunHook
import sbt._

object UIBuild {
  def apply(base: File): PlayRunHook = {
    object UIBuildHook extends PlayRunHook {

      var process: Option[Process] = None

      override def beforeStarted(): Unit = {
        if (!(base / "ui" / "node_modules").exists()) Process("npm install", base / "ui").!
      }

      override def afterStarted(addr: InetSocketAddress): Unit = {
        process = Option(
          Process("npm run build -- --watch", base / "ui").run
        )
      }

      override def afterStopped(): Unit = {
        process.foreach(_.destroy())
        process = None
      }

    }

    UIBuildHook
  }
} 
开发者ID:vinhbt,项目名称:statistic,代码行数:32,代码来源:UIBuild.scala

示例10: Webpack

//设置package包名称以及导入依赖的类
import play.sbt.PlayRunHook
import sbt._

object Webpack {
  def apply(base: File): PlayRunHook = {
    object WebpackHook extends PlayRunHook {
      var process: Option[Process] = None

      override def beforeStarted() = {
        println("Starting up....")
        process = Option(
          Process("webpack", base).run()
        )
      }

      override def afterStarted(addr: java.net.InetSocketAddress) = {
        println("afterStarted....")
        process = Option(
          Process("webpack --watch", base).run()
        )
      }

      override def afterStopped() = {
        println("afterStopped....")
        process.foreach(_.destroy())
        process = None
      }


      override def onError() : scala.Unit = {
        println("Crap happened.......")
      }
    }

    WebpackHook
  }
} 
开发者ID:howardfackrell,项目名称:renovator,代码行数:38,代码来源:Webpack.scala

示例11: UIBuild

//设置package包名称以及导入依赖的类
import java.net.InetSocketAddress

import play.sbt.PlayRunHook
import sbt._

object UIBuild {
  def apply(base: File): PlayRunHook = {
    object UIBuildHook extends PlayRunHook {

      var process: Option[Process] = None

      var npmInstall: String = "npm install"
      var npmRun: String = "npm run build -- --watch"

      // Windows requires npm commands prefixed with cmd /c
      if (System.getProperty("os.name").toLowerCase().contains("win")){
        npmInstall = "cmd /c" + npmInstall
        npmRun = "cmd /c" + npmRun
      }

      override def beforeStarted(): Unit = {
        if (!(base / "ui" / "node_modules").exists()) Process(npmInstall, base / "ui").!
      }

      override def afterStarted(addr: InetSocketAddress): Unit = {
        process = Option(
          Process(npmRun, base / "ui").run
        )
      }

      override def afterStopped(): Unit = {
        process.foreach(_.destroy())
        process = None
      }

    }

    UIBuildHook
  }
} 
开发者ID:lbialy,项目名称:play-ng2-webpack2,代码行数:41,代码来源:UIBuild.scala

示例12: Webpack

//设置package包名称以及导入依赖的类
import java.net.InetSocketAddress
import play.sbt.PlayRunHook
import sbt._

object Webpack {
  def apply(base: File): PlayRunHook = {
    object WebpackHook extends PlayRunHook {
      var process: Option[Process] = None

      override def beforeStarted() = {
        process = Option(
          Process("webpack", base).run()
        )
      }

      override def afterStarted(addr: InetSocketAddress) = {
        process = Option(
          Process("webpack --watch", base).run()
        )
      }

      override def afterStopped() = {
        process.foreach(_.destroy())
        process = None
      }
    }

    WebpackHook
  }
} 
开发者ID:nouhoum,项目名称:play-react-webpack,代码行数:31,代码来源:Webpack.scala


注:本文中的play.sbt.PlayRunHook类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。