sbt多度依赖

时间:2018-07-10 15:02:05

标签: scala sbt

我正在遵循此博客中的代码:https://pbassiner.github.io/blog/defining_multi-project_builds_with_sbt.html。它向我展示了如何创建具有依赖项的多项目构建。 multi1取决于common,multi2也取决于common。但是,如果我有2度依赖关系怎么办?即。 multi1取决于common,而multi2取决于multi1?

从此:常见-> mutli1;常见-> multi2 为此:常见-> multi1-> multi2

准确地说,这种依赖关系树如何更改此代码? (从博客复制)

lazy val global = project
  .in(file("."))
  .settings(settings)
  .aggregate(
    common,
    multi1,
    multi2
  )

lazy val common = project
  .settings(
    settings,
    libraryDependencies ++= commonDependencies
  )

lazy val multi1 = project
  .settings(
    settings,
    libraryDependencies ++= commonDependencies ++ Seq(
      dependencies.monocleCore,
      dependencies.monocleMacro
    )
  )
  .dependsOn(
    common
  )

lazy val multi2 = project
  .settings(
    settings,
    libraryDependencies ++= commonDependencies ++ Seq(
      dependencies.pureconfig
    )
  )
  .dependsOn(
    common
  )

1 个答案:

答案 0 :(得分:0)

  

common-> mutli1;常见-> multi2

表示milti1.dependsOn(common)milti2.dependsOn(common)

  

common-> multi1-> multi2

表示milti2.dependsOn(multi1)milti1.dependsOn(common)

因此,您只需要更改一行,即multi2取决于multi1(而不是common):

lazy val multi2 = project
  .settings(
    ...
  )
  .dependsOn(
    multi1
  )

传递依赖项按预期工作。