Play! 2.0 framework multi Module project

后端 未结 3 1303
情书的邮戳
情书的邮戳 2021-01-06 20:55

I would need to have two different projects, let\'s say internal and external, which use the same data layer, and I would like to avoid replicating the configuration file fo

3条回答
  •  伪装坚强ぢ
    2021-01-06 21:32

    A source dependency on a module living somewhere in your source tree can help you to achieve the build you want :

    import sbt._
    import Keys._
    import PlayProject._
    
    object ApplicationBuild extends Build {
    
        val appName         = "test"
        val appVersion      = "1.0-SNAPSHOT"
    
        val appDependencies = Seq(
          // Add your project dependencies here,
        )
    
        lazy val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings(
          // Add your own project settings here      
        ).dependsOn(common)
    
    
        lazy val common = RootProject(file("../common")) 
    
    
    }
    

    You cannot mix a play project with another, so your configuration should be in "dependencies". The good thing with source dependencies is they are live in your project (thanks to the recursivity of SBT). If the source of your dependency change, your main project get the change at the next compile.

    You can check the complete structure of my multimodule play app here: https://github.com/un-jon/play2MultiModule.

提交回复
热议问题