如何使sbt-assembly合并正确? [英] How to get sbt-assembly merge right?

查看:183
本文介绍了如何使sbt-assembly合并正确?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的Scala/Scalatra项目中,我们为插件sbt-assembly制定了以下合并策略:

In our Scala/Scalatra project, we have this merge policy for the plugin sbt-assembly:

assemblyMergeStrategy in assembly := {
  case x =>
   val oldStrategy = (assemblyMergeStrategy in assembly).value
   oldStrategy(x)
}

[错误]合并期间遇到11个错误 java.lang.RuntimeException:重复数据删除:在以下文件中找到不同的文件内容: 〜/.ivy2/cache/org.scalatra/scalatra_2.11/jars/scalatra_2.11-2.3.1.jar:mime.types 〜/.ivy2/cache/com.amazonaws/aws-java-sdk-s3/jars/aws-java-sdk-s3-1.10.1.jar:mime.types

[error] 11 errors were encountered during merge java.lang.RuntimeException: deduplicate: different file contents found in the following: ~/.ivy2/cache/org.scalatra/scalatra_2.11/jars/scalatra_2.11-2.3.1.jar:mime.types ~/.ivy2/cache/com.amazonaws/aws-java-sdk-s3/jars/aws-java-sdk-s3-1.10.1.jar:mime.types

重复数据删除:在以下文件中找到不同的文件内容:
〜/.ivy2/cache/commons-beanutils/commons-beanutils/jars/commons-beanutils-1.8.3.jar:org/apache/commons/collections/ArrayStack.class
〜/.ivy2/cache/commons-collections/commons-collections/jars/commons-collections-3.2.1.jar:org/apache/commons/collections/ArrayStack.class
重复数据删除:在以下文件中找到不同的文件内容:

deduplicate: different file contents found in the following:
~/.ivy2/cache/commons-beanutils/commons-beanutils/jars/commons-beanutils-1.8.3.jar:org/apache/commons/collections/ArrayStack.class
~/.ivy2/cache/commons-collections/commons-collections/jars/commons-collections-3.2.1.jar:org/apache/commons/collections/ArrayStack.class
deduplicate: different file contents found in the following:

并且对于不同的类名也存在相同的错误

and the same error for different class names

这里正确的合并逻辑是什么?

What would be the right merge logic here?

版本:

斯卡拉:2.11.7
SBT:0.13.9
sbt-assembly:0.13.0

Scala : 2.11.7
SBT : 0.13.9
sbt-assembly: 0.13.0

推荐答案

我的原始问题已通过以下方式解决:

My original issue was solved with:

assemblyMergeStrategy in assembly := {
  case PathList("org", "apache", "commons", "collections", xs @ _*) =>
      MergeStrategy.last
  case PathList("mime.types") =>
      MergeStrategy.last
  case x =>
      val oldStrategy = (assemblyMergeStrategy in assembly).value
      oldStrategy(x)
}

这篇关于如何使sbt-assembly合并正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆