多模块的平面目录结构?

时间:2012-03-24 17:53:53

标签: sbt

是否有可能,SBT对多模块使用平面目录结构?

也就是说,而不是:

- parent
  |- child_a
  |- child_b

简单地说:

- parent
- child_a
- child_b

我已尝试使用后者,并将父project/Build.scala配置为:

lazy val child_a = Project(id = "child_a",
    base = file("../child_a"))

但在执行sbt命令时,如sbt package,我会听到以下错误:

[error] java.lang.AssertionError: assertion failed: Directory D:\src\child_a is not contained in build root D:\src\parent

2 个答案:

答案 0 :(得分:0)

我认为这不可能。

答案 1 :(得分:0)

解决方案是ProjectRef

Directory ... not contained in build root ...Project-的问题,但不是ProjectRef 的问题。如果您切换到ProjectRef,它将消失。如果您在主项目的build.sbt中定义:

lazy val root = (project in file ("."))
    .aggregate(helper_library)
    .dependsOn(helper_library)

lazy val helper_library = ProjectRef(file("../helper_library"), "helper_library")

然后,helper_library和主项目是关于目录结构的同级兄弟(正如您在问题中所希望的那样),同时,主项目聚合到并依赖于helper_library