如何为项目创建sbt模板?

时间:2014-11-26 08:54:53

标签: scala maven build sbt

我有一个带有2个重复项目配置的sbt构建。见例:

lazy val MyProjectOne = Project(id = "OneId", base = file("path/OneId"))
    .dependsOn(moduleOne)
    .settings(plugin.settings: _*)
    .settings(defaultSettings: _*)
    .settings(webSettings: _*)
    .settings(libraryDependencies ++= commonTests)

lazy val MyProjectTwo = Project(id = "TwoId", base = file("path/TwoId"))
    .dependsOn(moduleOne)
    .settings(plugin.settings: _*)
    .settings(defaultSettings: _*)
    .settings(webSettings: _*)
    .settings(libraryDependencies ++= commonTests)

很明显MyProjectOneMyProjectTwo仅在idbase属性上有所不同。
有没有办法像这样重构sbt构建:

lazy val template = Project()
    .dependsOn(moduleOne)
    .settings(plugin.settings: _*)
    .settings(defaultSettings: _*)
    .settings(webSettings: _*)
    .settings(libraryDependencies ++= commonTests)

//Just as example:
lazy val MyProjectOne = Project(id = "OneId", base = file("path/OneId")).extends(template)
lazy val MyProjectTwo = Project(id = "TwoId", base = file("path/TwoId")).extends(template)

我怎么能用sbt做到这一点?

同时

使用maven,我可以为该案例定义父项目pom。在sbt中有模拟吗?

0 个答案:

没有答案