• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala PlayRunHook类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala CompletableFuture类代码示例发布时间:2022-05-23
下一篇:
Scala MediaType类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap