merge - 无法在多 jvm 节点测试中覆盖程序集合并策略

标签 merge sbt scalatest sbt-assembly

我无法覆盖依赖项的合并策略。

问题源于cassandra依赖独立的netty模块

val akkaCassandra = "com.typesafe.akka" %% "akka-persistence-cassandra" % "0.17"

如果我运行 graph-dependency,它会输出:

  | +-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

根据这个讨论,最好将合并策略定义为解决方案:

https://groups.google.com/a/lists.datastax.com/forum/#!msg/spark-connector-user/5muNwRaCJnU/sIHYh6PFEwAJ

Netty unfortunately has timing dependent markers in each io.versions.properties file in the metainfUntitled.jpg

This means the various components included all have different timestamps which is why everything is breaking. Unfortunately this is the underlying C* driver's dep, we could I guess exclude these netty modules from the driver and include netty-all in the connector instead but that seems like overkill.

I think just fixing the application build file is still the best solution.

据此,应该实现覆盖的能力:

https://github.com/typesafehub/sbt-multi-jvm/issues/22

Nested assembly config should be exposed for customization along with the other multijvm keys so that users can solve these issues.

i think that PR #19 will enable this functionality. the change at msfrank@fe862ff#diff-ad54d47177586fbaf474e402dd1b3dc5R137 will pass through the merge strategy defined with settings key (assemblyMergeStrategy in assembly) as long as the file is not one of *.class, *.txt, or NOTICE, which are hardcoded merge strategies

.

但是当我运行的时候

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

最佳答案

它对你不起作用,因为在你的代码中你覆盖了 sbt-assembly 任务的设置。

您需要做的是在 sbt-multi-jvm 插件的上下文中覆盖 sbt-assembly 的设置。

你可以这样做:

assemblyMergeStrategy in assembly in MultiJvm := {
  case x if x.endsWith("META-INF/io.netty.versions.properties") ⇒ MergeStrategy.first
}

关于merge - 无法在多 jvm 节点测试中覆盖程序集合并策略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39070874/

相关文章:

algorithm - 这个 K 路合并例程的运行时复杂度是多少?

python - 合并两个 pandas 数据框并根据条件创建一个新的二进制列

mysql - 我的代码中的 SlickConfig 和 Guice 配置错误

scala - sbt console - 为所有子项目设置 scala-version

scala - 在 sbt 中执行多个 Scalatest

python - 如何使用 Python 将多个工作表中的 .csv 文件合并为一个 .xls 文件?

iOS:核心数据合并策略如何影响 NSManagedObjectContext 保存和刷新操作

java - 在 Scala SBT 项目中导入 Accumulo 库

ScalaTest 深度对比最佳实践

unit-testing - 在 ScalaTest 中 `should` 、 `can` 、 `must` 之间有什么区别