玩! 2.0框架多模块项目 [英] Play! 2.0 framework multi Module project
问题描述
我需要有两个不同的项目,例如内部项目和外部项目,它们使用相同的数据层,并且我想避免由于干燥的原因而复制配置文件.
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 for dryness reasons.
我在 http://www.playframework.org上查看了子项目文档. /documentation/2.0.2/SBTSubProjects ,但是文档很短.
I have looked to the sub projects documentation at http://www.playframework.org/documentation/2.0.2/SBTSubProjects but the doc is pretty short.
由于@Georg Engel,我现在意识到可以模块化配置的可能性
I am now aware of the possibility to modularize the configuration, thanks to @Georg Engel
import sbt._
import Keys._
import PlayProject._
object ApplicationBuild extends Build {
val appName = "MyApp"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
// Add your project dependencies here,
)
lazy val common = Project(appName + "-common", file("modules/common"))
lazy val website = PlayProject(
appName + "-website", appVersion, path = file("modules/website")
).dependsOn(common)
lazy val adminArea = PlayProject(
appName + "-admin", appVersion, path = file("modules/admin")
).dependsOn(common)
lazy val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings(
// Add your own project settings here
).dependsOn(
website, adminArea
)
}
以及我的编译错误仅归因于反向路由器(取消路由但未导致控制器动作)
and the compilation errors I had where only due to the reverse router (canceling routes but not controller actions result in this)
推荐答案
我们正在使用这样的子模块(其中核心"是共享的子模块):
We are using submodules like this (where "core" is the shared submodule):
Build.scala
Build.scala
val coreModule = PlayProject(appName + "-core", "1.0", appDependencies, path = file("modules") / "core")
val main = PlayProject(appName + "-app", appVersion, appDependencies, mainLang = SCALA).settings(
// Add your own project settings here
).dependsOn(coreModule).aggregate(coreModule)
不幸的是,子模块必须位于项目树下("../core"因为路径不可能)-因此我们使用git子模块将共享模块放入树中:
Unfortunatelly submodules have to live under the project tree ("../core" as path isn't possible) - so we are using git submodules to get the shared module into the tree:
git submodule add git://git.example.com/modules.git modules
git submodule init
git submodule update
可能是SVN外部组件,辅助子模块等也可以完成这项工作.
Propably SVN externals, mercurial submodules etc. will do this job too.
这篇关于玩! 2.0框架多模块项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!