5

Using sbt-assembly 0.14.6:

addSbtPlugin("com.eed3si9n" %% "sbt-assembly" % "0.14.6")

Creating an uber jar for a Spark app with sbt-assembly, including a couple dependencies to be shaded:

libraryDependencies += "org.json4s" % "json4s-native_2.11" % "3.5.3",
libraryDependencies += "com.typesafe" % "config" % "1.3.3",

That's actually a second attempt, I really want to

libraryDependencies += "org.json4s" %% "json4s-native" % "3.5.3",
libraryDependencies += "com.typesafe" % "config" % "1.3.3",

but thought maybe shading was causing my trouble when using %% in the moduleID. So, what works and what doesn't:

sbt-assembly can shade a couple libraries like so:

assemblyShadeRules in assembly := Seq(
  ShadeRule.rename("org.json4s.**" -> "shaded_json4s.@1").inAll,
  ShadeRule.rename("com.typesafe.config.**" -> "my_conf.@1")
    .inLibrary("com.typesafe" % "config" % "1.3.3")
    .inProject
),

Example shaded classes:

my_conf/parser/ConfigNode.class
shaded_json4s/FieldSerializer.class

Both libraries get shaded. I'd like to get more specific, avoiding inAll:

assemblyShadeRules in assembly := Seq(
  ShadeRule.rename("org.json4s.**" -> "shaded_json4s.@1")
    .inLibrary("org.json4s" % "json4s-native_2.11" % "3.5.3")
    .inProject,
  ShadeRule.rename("com.typesafe.config.**" -> "my_conf.@1")
    .inLibrary("com.typesafe" % "config" % "1.3.3")
    .inProject
),

But that doesn't shade json4s classes:

my_conf/parser/ConfigNode.class
org/json4s/FieldSerializer.class

But what I started with, and would really prefer is:

assemblyShadeRules in assembly := Seq(
  ShadeRule.rename("org.json4s.**" -> "shaded_json4s.@1")
    .inLibrary("org.json4s" %% "json4s-native" % "3.5.3")
    .inProject,
  ShadeRule.rename("com.typesafe.config.**" -> "my_conf.@1")
    .inLibrary("com.typesafe" % "config" % "1.3.3")
    .inProject
),

But that doesn't shade json4s classes, either:

my_conf/parser/ConfigNode.class
org/json4s/FieldSerializer.class

Is there something I need to do differently for shading to work on json4s when using inLibrary?

Don Branson
  • 13,631
  • 10
  • 59
  • 101

0 Answers0