我想在某些Task中覆盖对项目的依赖。 我有一个使用spark的sbt多项目。
lazy val core = // Some Project
val sparkLibs = Seq(
"org.apache.spark" %% "spark-core" % "1.6.1"
)
val sparkLibsProvided = Seq(
"org.apache.spark" %% "spark-core" % "1.6.1" % "provided"
)
lazy val main = Project(
id = "main",
base = file("main-project"),
settings = sharedSettings
).settings(
name := "main",
libraryDependencies ++= sparkLibs,
dependencyOverrides ++= Set(
"com.fasterxml.jackson.core" % "jackson-databind" % "2.4.4"
)
).dependsOn(core)
当我尝试在我的纱线群集上提交胖罐时,我使用https://github.com/sbt/sbt-assembly任务。但在这种情况下,我想使用sparkLibsProvided
代替sparkLibs
之类的内容:
lazy val sparkProvided = (project in assembly).settings(
dependencyOverrides ++= sparkLibsProvided.toSet
)
如何正确覆盖此依赖关系?
答案 0 :(得分:3)
您可以创建一个新项目,这是一个专门的项目,用于使用提供的标志创建spark uber jar:
lazy val sparkUberJar = (project in file("spark-project"))
.settings(sharedSettings: _*)
.settings(
libraryDependencies ++= sparkLibsProvided,
dependencyOverrides ++= Set(
"com.fasterxml.jackson.core" % "jackson-databind" % "2.4.4"
)
)
当你在sbt中聚集时,首先去上述项目:
sbt project sparkUberJar
sbt assembly
答案 1 :(得分:0)