How to deduplicate beanutils dependencies with sbt-assembly?

I have a project with several dependencies that ultimately result in depending on the following (I got them from the sbt-dependency-graph plugin ):

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

As a result, when I try to create a thick JAR using sbt-assembly , it fails with deduplication errors like:

[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

Since I need both dependencies, I tried to obscure 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

But then I get the following error:

[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

As if the shading process applied to both artifacts. How to obscure a particular artifact?

+4
source share
1

, , :

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?)

+2

Source: https://habr.com/ru/post/1619377/


All Articles