如何使用commons-beanutils对beanutils依赖项进行重复数据删除?

问题描述 投票:6回答:1

我有一个项目有几个依赖项,最终导致取决于以下(我从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个回答
4
投票

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

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(...)电话的目的。也许我在自述文件中描述它的方式还不够明确。

我想你想做的是把inLibrary(...)用于commons-beanutils 1.7.0以及所有调用commons-beanutils 1.7.0代码为org.apache.commons.beanutils.**的调用者(在这种情况下是Hadoop?)

© www.soinside.com 2019 - 2024. All rights reserved.