sbt-assembly
sbt-assembly copied to clipboard
Shading with inLibrary doesn't work
Hi! I am trying to use ShadeRule.rename().inLibrary()
but I am unable to make it work with sbt-assembly
0.15.0 and 0.14.10. I use sbt 1.0.4 with Scala 2.11.12.
Some context: I am using the "com.azure" % "azure-storage-blob" % "12.8.0"
library which depends on io.netty
. My goal is to shade all io.netty
references in azure-storage-blob
only. I want all other libraries which depend on Netty to use the provided
version.
In order to achieve this, I wanted to use inLibrary
but I couldn't make it work. It either doesn't shade anything at all, or it shades all io.netty
packages but doesn't update the references in azure-storage-blob
classes.
The only way to make shading work seems to be inAll
but this also shades io.netty
in all other libraries which I do not want.
I have a sample project which reproduces the issue and I have described all of the tests I've done in the README: https://github.com/antonipp/sbt-shade-rule-test/
Any help would be really appreciated!
met the same with sbt-1.3.10 and sbt-assembly-0.14.10
Same with sbt 1.4.3 and assembly-0.14.10.
Same with sbt 1.4.8 and sbt-assembly 1.0.0
Hi
Any update on this please? I am also experiencing this Scala 2.12.13 SBT assembly 1.1.1 SBT 1.9.2
The same for Scala 2.12.15 SBT 1.9.2 sbt-assembly 0.15.0
Addition after tests.
I've done it.
It has to add .inAll
or .inProject
after a rule.
For example,
assembly / assemblyShadeRules := Seq(
ShadeRule.rename("org.apache.http.**" -> "shaded.httpclient.org.apache.http.@1")
.inLibrary("com.company.somePackage" % "my-lib-kit" % "x.x.x")
.inAll
)
@antonipp some years later :)
So let's take a look at your dependency graph:
project -> azure-storage-blob-> azure-storage-common-> azure-core-http-netty -> io.netty
inLibrary
is a bit dumb, it does not transitively collect all the dependencies, so you need to look at your dependency graph and pick the libraries you need to shade.
For the others, if you have a Scala library, there is also this bug to take into consideration: https://github.com/sbt/sbt-assembly/issues/403
a clarification to @avgolubev comment:
if you are using inLibrary
you are being more specific on the targets you want to apply shading to. If you use .inAll
it will apply the shading to all the library regardless of your inLibrary
filter.
This project will shade their transitive dependencies correctly: https://github.com/coursier/sbt-shading#sbt-shading