如何使用 commons-beanutils 删除重复的 beanutils 依赖项?

How to deduplicate beanutils dependencies with commons-beanutils?

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

因此,当我尝试使用 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

好像对两个工件都应用了着色处理。如何为特定工件着色?

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

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

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

话虽如此,我认为 .inAll 违背了您 .inLibrary(...) 调用的目的。可能我在README上描述的不够清楚。

我认为你想要做的是将 inLibrary(...) 用于 commons-beanutils 1.7.0 所有引用 commons-beanutils 1.7 的调用者.0 代码为 org.apache.commons.beanutils.**(在本例中为 Hadoop?)