gpt4 book ai didi

scala - sbt-assembly 排除 dependsOn 依赖

转载 作者:行者123 更新时间:2023-12-05 07:32:55 24 4
gpt4 key购买 nike

我有一个包含几个子项目和许多依赖项的项目,一个子项目将进行大部分开发(应用程序)并且生成完整的 jar 需要时间。所以我想将 fat-jar 生成分成 2 个 jar :

  • deps 一个 fat-jar
  • 应用精益 jar

我希望创建一个像这样的 deps 项目:

lazy val deps = (project in file("deps"))
.settings(
libraryDependencies ++= commonDependencies,
assemblyJarName in assembly := "deps.jar",
assemblyMergeStrategy in assembly := {
case m if m.toLowerCase.endsWith("manifest.mf") => MergeStrategy.discard
case m if m.toLowerCase.matches("meta-inf.*\\.sf$") => MergeStrategy.discard
case m if m.toLowerCase.startsWith("meta-inf/services/") => MergeStrategy.filterDistinctLines
case m if m.toLowerCase.endsWith(".dct") => MergeStrategy.first
case "reference.conf" => MergeStrategy.concat
case _ => MergeStrategy.first
}
).dependsOn(
measurement,
streaming,
domain
)

我的应用项目如下:

lazy val app = (project in file("my-app"))
.settings(clientEventSettings)
.settings(noPublishSettings)
.settings(
assemblyJarName in assembly := "my-app.jar",
assemblyMergeStrategy in assembly := {
case m if m.toLowerCase.endsWith("manifest.mf") => MergeStrategy.discard
case m if m.toLowerCase.matches("meta-inf.*\\.sf$") => MergeStrategy.discard
case m if m.toLowerCase.startsWith("meta-inf/services/") => MergeStrategy.filterDistinctLines
case m if m.toLowerCase.endsWith(".dct") => MergeStrategy.first
case "reference.conf" => MergeStrategy.concat
case _ => MergeStrategy.first
})
.dependsOn( //<- but do not package??
measurement,
streaming,
messagingDomain,
messagingKafkaToolkit,
domain,
analyticsWebtrekk,
commons
)

编译明智的 my-app 项目依赖于其他子项目 (deps),但它应该在 provided 范围内,因为我不希望它被 sbt-assembly 打包。

我将尝试使用 libraryDependencies,但我认为这意味着克隆 commonDependencies,所有这些都在 provided 范围内。

最佳答案

readme sbt-assembly 提供了答案:在部分中:Splitting your project and deps JARs

assemblyOption in assembly := (assemblyOption in assembly).value.copy(includeScala = false, includeDependency = false)

关于scala - sbt-assembly 排除 dependsOn 依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50924584/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com