问题
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?
回答1:
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
)
来源:https://stackoverflow.com/questions/24596914/sbt-assembly-rename-class-with-merge-conflicts-shade