I am trying to shade com.google.gson to my_gson and added assemblyShadeRules to my build.sbt:
assemblyShadeRules in assembly ++= Seq(
ShadeRule.rename("com.google.gson.**" -> "my_gson.@1")
.inLibrary("com.google.code.gson" % "gson" % "2.8.9")
.inProject
)
According to this: how to shade before compile with SBT? when we shade the dependency using assemblyShadeRules, the import statement should change and be updated from e.g.
import com.google.gson.{Gson, JsonArray, JsonObject}
into my_gson.{Gson, JsonArray, JsonObject}
The thing is it is still shwoing as com.google.gson
I am unsure why. i am currently using intellij as my IDE but the change is not reflected even after i did the shading as per My build.sbt here:
name := "CMS Leakage Detection"
version := "3.0"
scalaVersion := "2.12.15"
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-sql" % "3.3.0",
"com.google.code.gson" % "gson" % "2.8.9",
"com.google.cloud.spark" %% "spark-bigquery-with-dependencies" % "0.26.0" % "provided",
"com.typesafe" % "config" % "1.3.2",
"com.jcraft" % "jsch" % "0.1.55",
"org.springframework" % "spring-web" % "5.3.18",
"org.apache.httpcomponents" % "httpcore" % "4.4.15",
"org.apache.httpcomponents" % "httpclient" % "4.5.13"
)
excludeDependencies ++= Seq(
ExclusionRule("org.apache.hadoop", "commons-logging")
)
scalacOptions ++= Seq("-Xmax-classfile-name","80")
assemblyMergeStrategy in assembly := {
case PathList("META-INF", _*) => MergeStrategy.discard
case _ => MergeStrategy.first
}
assemblyShadeRules in assembly ++= Seq(
ShadeRule.rename("com.google.gson.**" -> "my_gson.@1")
.inLibrary("com.google.code.gson" % "gson" % "2.8.9")
.inProject
)
I am expecting the import statement to show: e.g.)
import my_gson.JsonObject
running jar tvf .../path-to-my-jar
is also showing that the dependency is not shaded, output:
Fri Jan 01 00:00:00 SGT 2010 com/google/gson/JsonObject.class
i created a file called plugins.sbt inside my project folder /Users/myname/Desktop/repo/projIamWorkingOn/project/plugins.sbt and it contains only the following, its so that i can use sbt assembly
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.2.0")