我无法覆盖依赖项的合并策略。
问题源于cassandra依赖于单独的netty模块
val akkaCassandra = "com.typesafe.akka" %% "akka-persistence-cassandra" % "0.17"
如果我运行图依赖,它会输出:
| +-io.netty:netty-handler:4.0.33.Final
[info] | +-io.netty:netty-buffer:4.0.33.Final
[info] | | +-io.netty:netty-common:4.0.33.Final
[info] | |
[info] | +-io.netty:netty-codec:4.0.33.Final
[info] | | +-io.netty:netty-transport:4.0.33.Final
[info] | | +-io.netty:netty-buffer:4.0.33.Final
[info] | | +-io.netty:netty-common:4.0.33.Final
[info] | |
[info] | +-io.netty:netty-transport:4.0.33.Final
[info] | +-io.netty:netty-buffer:4.0.33.Final
[info] | +-io.netty:netty-common:4.0.33.Final
根据此讨论,最好将合并策略定义为解决方案:
不幸的是,Netty每个都有时间依赖标记 metainfUntitled.jpg中的io.versions.properties文件
这意味着包含的各种组件都有不同 时间戳这就是为什么一切都破裂的原因。不幸的是这是 基础C *驱动程序的dep,我猜我们可以排除这些netty 来自驱动程序的模块,并在连接器中包含netty-all 但这似乎有点矫枉过正。
我认为修复应用程序构建文件仍然是最好的 溶液
根据这一点,应该实施覆盖的能力:
https://github.com/typesafehub/sbt-multi-jvm/issues/22
应公开嵌套程序集配置以进行自定义 其他multijvm键,以便用户可以解决这些问题。
我认为PR#19将启用此功能。改变了 msfrank @ fe862ff #diff-ad54d47177586fbaf474e402dd1b3dc5R137将通过 通过使用设置键定义的合并策略 (assemblyMergeStrategy in assembly)只要文件不是其中之一 * .class,* .txt或NOTICE,这是硬编码合并策略
但是当我跑步时
sbt:multi-node-test
lazy val test = Project(id = "core-tests", base = file("./modules/core/tests"))
.settings(SbtMultiJvm.multiJvmSettings: _*)
.settings(
libraryDependencies ++= Dependencies.coreTests,
assemblyMergeStrategy in assembly := {
case x if x.endsWith("META-INF/io.netty.versions.properties") ⇒ MergeStrategy.first
},
compile in MultiJvm <<= (compile in MultiJvm) triggeredBy (compile in Test),
parallelExecution in Test := false,
executeTests in Test <<= (executeTests in Test, executeTests in MultiJvm) map {
case (testResults, multiNodeResults) ⇒
val overall =
if (testResults.overall.id < multiNodeResults.overall.id)
multiNodeResults.overall
else
testResults.overall
Tests.Output(overall,
testResults.events ++ multiNodeResults.events,
testResults.summaries ++ multiNodeResults.summaries)
},
licenses := Seq(("CC0", url("http://creativecommons.org/publicdomain/zero/1.0"))),
Settings.levelDb, Settings.test)
我仍然拒绝使用合并策略,我定义了。
[error] 1 error was encountered during merge
[trace] Stack trace suppressed: run 'last core-tests/multi-jvm:assembly' for the full output.
[error] (core-tests/multi-jvm:assembly) deduplicate: different file contents found in the following:
[error] ~/.ivy2/cache/io.netty/netty-handler/jars/netty-handler-4.0.33.Final.jar:META-INF/io.netty.versions.properties
[error] ~/.ivy2/cache/io.netty/netty-buffer/jars/netty-buffer-4.0.33.Final.jar:META-INF/io.netty.versions.properties
[error] ~/.ivy2/cache/io.netty/netty-common/jars/netty-common-4.0.33.Final.jar:META-INF/io.netty.versions.properties
[error] ~/.ivy2/cache/io.netty/netty-transport/jars/netty-transport-4.0.33.Final.jar:META-INF/io.netty.versions.properties
[error] ~/.ivy2/cache/io.netty/netty-codec/jars/netty-codec-4.0.33.Final.jar:META-INF/io.netty.versions.propertie
答案 0 :(得分:1)
它不适合您,因为在您的代码中,您覆盖了sbt-assembly
任务的设置。
您需要做的是在sbt-assembly
插件的上下文中覆盖sbt-multi-jvm
的设置。
你可以这样做:
assemblyMergeStrategy in assembly in MultiJvm := {
case x if x.endsWith("META-INF/io.netty.versions.properties") ⇒ MergeStrategy.first
}
答案 1 :(得分:0)
这些文件具有不同的内容,将它们串联起来并没有多大危害:
assemblyMergeStrategy in assembly := {
case PathList("META-INF", "io.netty.versions.properties") =>
MergeStrategy.concat
case x =>
val oldStrategy = (assemblyMergeStrategy in assembly).value
oldStrategy(x)
}
然后查看内容:
unzip -p YOUR_ASSEBMBLY.jar "META-INF/io.netty.versions.properties"