玩!2.0框架多Module项目 [英] Play! 2.0 framework multi Module project

查看:22
本文介绍了玩!2.0框架多Module项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有两个不同的项目,比如说内部和外部,它们使用相同的数据层,我想避免由于干燥原因复制配置文件.

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)

推荐答案

我们正在使用这样的子模块(其中core"是共享子模块):

We are using submodules like this (where "core" is the shared submodule):

构建.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 外部组件、mercurial 子模块等也可以完成这项工作.

Propably SVN externals, mercurial submodules etc. will do this job too.

这篇关于玩!2.0框架多Module项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆