sbt-assembly: Rename Class with merge conflicts (shade)
Asked Answered
B

1

3

How can I tell sbt-assembly to keep its existing merge / deduplicate rules, except, when two .class files conflice, rename (and issue a warning so I know about it)?

Would this be identical to the shade strategy used in Maven?

Bogosian answered 6/7, 2014 at 14:34 Comment(0)
R
5

The rename strategy literally just renames the file and it doesn't change the contents, so it won't work for .class files. The main use case for rename is for LICENSE files.

Updated in September 2015:

sbt-assembly 0.14.0 adds shading support.

sbt-assembly can shade classes from your projects or from the library dependencies. Backed by Jar Jar Links, bytecode transformation (via ASM) is used to change references to the renamed classes.

assemblyShadeRules in assembly := Seq(
  ShadeRule.rename("org.apache.commons.io.**" -> "shadeio.@1").inAll
)
Robet answered 6/7, 2014 at 16:17 Comment(4)
Thanks. Does sbt-assembly support anything like shade?Bogosian
So there's no solution to the shading problem in sbt? Should I really change to maven? This su*ks...Christoper
There's a Github issue now to petition for this feature - github.com/sbt/sbt-assembly/issues/156Robet
And now shade support has been merged into sbt#master!Petry

© 2022 - 2024 — McMap. All rights reserved.