SBT how to use shading to ensure AWS library uses old version of netty, while project uses latest?

46 Views Asked by At

We have a build file with

val awssdk2 = "2.15.14"
val netty = "4.1.91.Final"

...
      "software.amazon.awssdk" % "kinesis"      % Versions.awssdk2,
      "io.netty"               % "netty-buffer" % Versions.netty

Now this version of the awssdk pulls in 4.1.46.Final of netty, which gets evicted by 4.1.91.Final, which breaks some of the awssdk (some dodgy bug or incompatibility in Netty). (It causes java.nio.channels.ClosedChannelException)

We want to tell sbt to "shade" netty in the awssdk so that calls to awssdk result in calls to the 4.1.46.Final version of netty, and calls to everything else in the project (like our own netty code, or other libraries that use netty) use 4.1.91.Final.

Now we know we can bump the awssdk2 version and get things working that way, but this SO is only showing a tiny fragment of a very large build file, and we need a general mechanism of making libraries use their own versions of things.

Perhaps we don't fully understand what shading is supposed to do, but anyway we tried this:

    assemblyShadeRules in assembly ++= Seq(
      ShadeRule.rename("io.netty.**" -> "aws2_version_of_netty.@1")
        .inLibrary("software.amazon.awssdk" % "kinesis" % Versions.awssdk2)
    ),

and it has no impact - same error.

0

There are 0 best solutions below