sbt-assembly 是否应该对 类 执行类似 "maven-shade-plugin" 的重定位?
Should sbt-assembly perform a "maven-shade-plugin"-like relocation of classes?
sbt-assembly merge strategy called rename sounded like it might permit something similar to the shading operation of the maven-shade-plugin 的描述将重新定位 类 及其引用,以允许管理不兼容版本的库。
sbt-assembly 执行该功能是否合适?
我使用了以下合并策略来尝试将重命名用作重定位机制,但是当它匹配所有文件时,它会直接传递它们(这与查看代码一致)。
assemblyMergeStrategy in assembly := { s =>
s match {
case PathList("com", "clearspring", "analytics", _*) => {
println("match_cs: " + s)
MergeStrategy.rename
}
case x => {
println("x: " + x)
val oldStrategy = (assemblyMergeStrategy in assembly).value
oldStrategy(x)
}
}
}
2015 年 9 月更新:
sbt-assembly 0.14.0 添加了 shading 支持。
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
)
sbt-assembly merge strategy called rename sounded like it might permit something similar to the shading operation of the maven-shade-plugin 的描述将重新定位 类 及其引用,以允许管理不兼容版本的库。
sbt-assembly 执行该功能是否合适?
我使用了以下合并策略来尝试将重命名用作重定位机制,但是当它匹配所有文件时,它会直接传递它们(这与查看代码一致)。
assemblyMergeStrategy in assembly := { s =>
s match {
case PathList("com", "clearspring", "analytics", _*) => {
println("match_cs: " + s)
MergeStrategy.rename
}
case x => {
println("x: " + x)
val oldStrategy = (assemblyMergeStrategy in assembly).value
oldStrategy(x)
}
}
}
2015 年 9 月更新:
sbt-assembly 0.14.0 添加了 shading 支持。
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
)