SBT 子项目不起作用?



>我有一个看起来像这样的构建

thing/ build.sbt clientserver/ build.sbt client/ ... server/ ...

//build.sbt val clientserver = project.in(file("clientserver"))...

//clientserver/build.sbt val client = project.in(file("client"))... val server = project.in(file("server"))...

如何在 SBT 控制台中引用这些子项目? clientserver/client/compileclientserver.client/compile不起作用

必须在顶级生成中定义所有项目定义。但是,您很可能拥有基目录深 2 级的项目。

因此,对于您的示例,您应该在thing/build.sbt中具有以下内容:

lazy val clientserver = project.in(file("clientserver"))...
lazy val clientserverClient = project.in(file("clientserver/client"))...
lazy val clientserverServer = project.in(file("clientserver/server"))...

因此,在 sbt 控制台中,它们分别被引用为 clientserverClientclientserverServer

你如何使用 sbt?意思是,通过 IDE 还是命令行?我在 IntelliJ 中的多模块项目遇到了问题,但最近的更新解决了我的问题。

更新包括IntelliJ本身(从13.3到14.0)和scala插件到1.1版本。

当我以前从非 IDE 运行我的项目时,一切都很顺利,但是当我切换到 IntelliJ 时,它是自动创建模块 scala 方面以及使其无法编译的原因。第二个问题是包含空格字符的文件夹名称 - UriException。这两个更新都解决了问题。

你能检查它是否适用于cmd线吗?如果是这样,你能把所有子模块的定义都放到'thing/build.sbt'并尝试一下吗?我将我的项目定义为下面的代码片段,但在 Scala 对象(扩展构建特征)中,它就像一个魅力。

lazy val root = Project(
    id = "root",
    file ("."),
    settings = buildSettings
              ++ Seq (description := "root")
              ++ Seq (libraryDependencies ++= commonDependencies)
    ) aggregate core
lazy val core = Project(
    id = "Core",
    base = file ("Core module"),
    settings = buildSettings
              ++ Seq (description := "Core desc")
              ++ Seq (libraryDependencies ++= commonDependencies)
    )

最新更新