2015-12-10 44 views
4

我有几个依赖一个项目,这最终导致 取决于以下(我得到了这些来自sbt-dependency-graph plugin):如何用sbt-assembly重复删除beanutils依赖关系?

  • commons-beanutils:commons-beanutils:1.7.0
  • commons-beanutils:commons-beanutils-core:1.8.0

因此,当我尝试使用sbt-assembly来构建胖胖的JAR,它会因重复数据删除错误而失败:

[error] deduplicate: different file contents found in the following: 
[error] /Users/someuser/.ivy2/cache/commons-beanutils/commons-beanutils/jars/someuser-beanutils-1.7.0.jar:org/apache/commons/beanutils/BasicDynaBean.class 
[error] /Users/someuser/.ivy2/cache/commons-beanutils/commons-beanutils-core/jars/commons-beanutils-core-1.8.0.jar:org/apache/commons/beanutils/BasicDynaBean.class 

因为我两者都需要依赖关系,我想树荫其中之一使用以下规则:

ShadeRule.rename("org.apache.commons.beanutils.**" -> "[email protected]").inLibrary("commons-beanutils" % "commons-beanutils" % "1.7.0").inAll 

但后来我得到以下错误:

[error] deduplicate: different file contents found in the following: 
[error] /Users/someuser/.ivy2/cache/commons-beanutils/commons-beanutils/jars/someuser-beanutils-1.7.0.jar:shadedstuff/beanutils/BasicDynaBean.class 
[error] /Users/someuser/.ivy2/cache/commons-beanutils/commons-beanutils-core/jars/commons-beanutils-core-1.8.0.jar:shadedstuff/beanutils/BasicDynaBean.class 

仿佛被施加阴影处理到两个文物。如何遮蔽特定的神器?

回答

2

Since I need both dependencies, I tried to shade one of them using the following rule:

ShadeRule.rename("org.apache.commons.beanutils.**" -> "[email protected]").inLibrary("commons-beanutils" % "commons-beanutils" % "1.7.0").inAll 

阴影是对SBT组装,基本上与Jar Jar Links集成了贡献功能,所以我不是这方面的专家。

话虽如此,我认为.inAll击败你的.inLibrary(...)电话的目的。也许我在README上描述它的方式还不够清楚。

我想你想要做的就是把inLibrary(...)对公地的BeanUtils 1.7.0 所有来电者是谁指公地的BeanUtils 1.7.0代码org.apache.commons.beanutils.**(在这种情况下,Hadoop的?)

+0

确实。删除'.inAll'解决了这个问题。我误解了文档,但现在一切似乎都很清楚。非常感谢支持。 – ale64bit

+0

@ ale64bit,你可以请一个工作'build.sbt'文件的片段。我有一个类似的问题,而取决于'org.apache.hadoop:hadoop-aws:2.7.3'。 – Interfector