PlayRunHook does not work in multi module projects

跟風遠走 提交于 2019-12-08 15:19:32
  1. In sbt keep only one build.sbt file and one project directory (with *.sbt and *.scala config files)
  2. Copy WebPack.scala to project directory.
  3. Move your root project to subproject (base).
  4. Rewrite build.sbt
    import play.sbt.PlayImport.PlayKeys.playRunHooks

    name := """root"""

    version := "1.0-SNAPSHOT"

    val scraperDir = "modules/scraper"

    val sliderDir = "modules/slider"

    lazy val commonSettings = Seq(
        scalaVersion := "2.11.7",
        libraryDependencies ++= Seq(
           jdbc,
           cache,
           ws,
           specs2 % Test
        ),
        resolvers ++= Seq(
           "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"
        )
    )

    lazy val base = projectName("base","base").settings(
        playRunHooks += WebPack.apply(file(scraperDir))
    )
   .dependsOn(scraper,slider)

    lazy val scraper = projectName("scraper", scraperDir).settings(
       libraryDependencies ++= Seq(
           "com.corundumstudio.socketio" % "netty-socketio" % "1.7.8"
       ),
       resolvers ++= Seq(
          "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots")
    )

    lazy val slider = projectName("slider", sliderDir)

    def projectName(name: String, path: String): Project =
     Project(name,file(path))
     .settings(
         commonSettings,
         routesGenerator := InjectedRoutesGenerator
     )
     .enablePlugins(PlayScala)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!