【问题标题】:How to deduplicate beanutils dependencies with commons-beanutils?如何使用 commons-beanutils 去重 beanutils 依赖项?
【发布时间】:2016-03-16 07:52:48
【问题描述】:

我有一个项目有几个依赖项,最终导致 取决于以下内容(我从sbt-dependency-graph plugin 得到这些):

  • 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.**" -> "shadedstuff.beanutils.@1").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

好像着色过程应用于两个工件。如何为特定的工件着色?

【问题讨论】:

标签: dependencies sbt sbt-assembly maven-shade-plugin


【解决方案1】:

由于我需要两个依赖项,因此我尝试使用以下规则对其中一个进行遮蔽:

ShadeRule.rename("org.apache.commons.beanutils.**" -> "shadedstuff.beanutils.@1").inLibrary("commons-beanutils" % "commons-beanutils" % "1.7.0").inAll

Shading 是 sbt-assembly 的贡献功能,它基本上与 Jar Jar Links 集成,所以我不是这方面的专家。

话虽如此,我认为.inAll 违背了您拨打.inLibrary(...) 的目的。也许我在 README 中描述的方式不够清楚。

我认为您想要做的是将 inLibrary(...) 用于 commons-beanutils 1.7.0 所有将 commons-beanutils 1.7.0 代码称为 org.apache.commons.beanutils.** 的调用者(在这种情况下是 Hadoop?)

【讨论】:

  • 确实如此。删除 .inAll 可解决此问题。我误解了文档,但现在一切似乎都很清楚。非常感谢您的支持。
  • @ale64bit,能否请您提供正在工作的build.sbt 文件的sn-p。我在依赖 org.apache.hadoop:hadoop-aws:2.7.3 时遇到了类似的问题。
猜你喜欢
  • 2014-02-02
  • 2013-01-02
  • 2011-04-25
  • 2013-01-24
  • 1970-01-01
  • 2018-01-02
  • 2011-11-14
  • 1970-01-01
  • 2017-06-14
相关资源
最近更新 更多