我的build.sbt
:
lazy val someDeps = Seq(
libraryDependencies += "com.example" %% "foo" % "1.3.37",
// more
)
lazy val some_library = project.in(file("libs/somelibrary")).
settings(commonSettings).
settings(
// project-specific settings
libraryDependencies ++= someDeps
)
lazy val something_with_deps_provided = project.in(file("swdp")).
settings(commonSettings).
settings(
// project-specific settings
libraryDependencies ++= someDeps.map(d => d % "provided")
).dependsOn(some_library)
当我现在使用sbt-assembly-plugin
创建something_with_deps_provided
的程序集时,它仍会将依赖项放入生成的jar中,忽略provided
。以后是否可以将传递依赖性设置为provided
,如果是,它是如何完成的?
答案 0 :(得分:0)
在这种情况下,可以按照以下说明使用excludeDependencies
SBT手册在这里:
Exclude Transitive Dependencies。
以您的示例为例:
lazy val something_with_deps_provided = project.in(file("swdp"))
.settings(commonSettings)
.dependsOn(some_library)
.settings(
// project-specific settings
excludeDependencies ++= someDeps.map { d =>
ExclusionRule(
organization = d.organization,
name = d.name
)
}
)
来自someDeps
的依赖项将不再包含在
something_with_deps_provided
项目的程序集JAR。