How to exclude jar in final sbt assembly plugin

夙愿已清 提交于 2020-01-13 04:29:25

问题


I need to exclude spark and test dependencies from my final assembly jar. I tried to use provider but it was not working.

libraryDependencies ++= Seq("org.apache.spark" % "spark-core_2.11" % "2.0.1" % "provided")

and execute sbt assembly.

Please help me resolve this issue.


回答1:


Use exclude option of assembly plugin filtering by direct name or with contains

assemblyExcludedJars in assembly := {
    val cp = (fullClasspath in assembly).value
    cp filter { f =>
      f.data.getName.contains("spark-core") ||
      f.data.getName == "spark-core_2.11-2.0.1.jar"
    }
  }



回答2:


I don't think || works. Instead use:

assemblyExcludedJars in assembly := {

var cp = (fullClasspath in assembly).value

cp     = cp filter { f=>f.data.getName.contains("spark-core")}

cp     = cp filter { f=>f.data.getName.contains("spark-core_2.11-2.0.1.jar")

 }

}


来源:https://stackoverflow.com/questions/41894055/how-to-exclude-jar-in-final-sbt-assembly-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!