sbt Build.scala 上的库依赖性带有子项目的完整配置

发布于 2024-11-26 03:33:29 字数 1566 浏览 1 评论 0原文

我有一个项目 foo 有两个孩子 foo-core 和 foo-cli,foo-cli 依赖于 foo-core (我来自 Java/Maven,并尝试将父模块转置为 2 个子模块架构)。 遵循https://github.com/harrah/xsbt/wiki/Full-Configuration,我这样写了我的项目/Build.scala:

import sbt._
import Keys._

object MyBuild extends Build {
      //Dependencies
      val slf4s = "com.weiglewilczek.slf4s" %% "slf4s" % "1.0.6"
      val slf4j = "org.slf4j" %% "slf4j-simple" % "1.5.6"
      val grizzled = "org.clapper" %% "grizzled-slf4j" % "0.5"
      val junit = "junit" % "junit" % "4.8" % "test"
      //End dependencies

  lazy val root : Project = Project("root", file(".")) aggregate(cli) settings(
    mainClass:= Some("Main")
  )

  lazy val core : Project = Project("core", file("core"), delegates = root :: Nil) settings(
    name := "foo-core",
    libraryDependencies ++= Seq(grizzled)

    )

  lazy val cli: Project = Project("cli", file("cli")) dependsOn(core) settings(
    name := "foo-cli",
    libraryDependencies ++= Seq(grizzled)
    )
}

此配置不起作用:当我运行 sbt reload;sbt +update 时,不会下载 grizzled 库(如 http://software.clapper.org/grizzled-slf4j/),因此“导入 grizzli ._" 当我 sbt 编译时,我的核心和 cli 项目失败。

由于我是 scala/sbt 的新手,我想我正在做一些可怕的事情,但无法弄清楚为什么,因为我对建议的所有 sbt 0.7/sbt0.10 冲突配置感到困惑 (例如SBT 中的子项目依赖项)。

有什么想法吗?提示可以帮助我吗?

提前致谢

I have a project foo with two children foo-core and foo-cli, foo-cli depends on foo-core
(I come from Java/Maven and tried to transpose the parent module with 2 submodules architecture).
Following https://github.com/harrah/xsbt/wiki/Full-Configuration, I wrote my project/Build.scala this way:

import sbt._
import Keys._

object MyBuild extends Build {
      //Dependencies
      val slf4s = "com.weiglewilczek.slf4s" %% "slf4s" % "1.0.6"
      val slf4j = "org.slf4j" %% "slf4j-simple" % "1.5.6"
      val grizzled = "org.clapper" %% "grizzled-slf4j" % "0.5"
      val junit = "junit" % "junit" % "4.8" % "test"
      //End dependencies

  lazy val root : Project = Project("root", file(".")) aggregate(cli) settings(
    mainClass:= Some("Main")
  )

  lazy val core : Project = Project("core", file("core"), delegates = root :: Nil) settings(
    name := "foo-core",
    libraryDependencies ++= Seq(grizzled)

    )

  lazy val cli: Project = Project("cli", file("cli")) dependsOn(core) settings(
    name := "foo-cli",
    libraryDependencies ++= Seq(grizzled)
    )
}

This configuration does not work: grizzled library is not dowloaded when I run sbt reload;sbt +update (as indicated in http://software.clapper.org/grizzled-slf4j/) and thus the "import grizzli._" fail in my core and cli projects when I sbt compile.

Since I'm new to scala/sbt I imagine I'm doing something awful but can't figure why since I'm confused with all sbt 0.7/sbt0.10 conflicting configurations that were suggested
(like Subproject dependencies in SBT).

Any idea? Hint that could help me?

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

诗化ㄋ丶相逢 2024-12-03 03:33:29

那是 grizzled,而不是您用作依赖项的 grizzli。导入是:

import grizzled._

这可以从 project cliproject core 上的 console 运行,只需要上面的配置文件即可。

您使用的是 SBT 0.10 吗?

That's grizzled, not grizzli you are using as dependency. The import is:

import grizzled._

This works here from console on project cli and project core, with nothing more than the configuration file above.

Are you using SBT 0.10?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文