i try to create a fat jar using the sbt assembly plugin. While importing several (problem-unrelated) dependencies in commonSetting with scala version 2.11.8, the build.sbt looks as follows:
lazy val root = (project in file("."))
.settings(commonSettings: _*)
.settings(
name := "stream",
mainClass in Compile := Some("stream.Streaming"),
mainClass in assembly := Some("stream.Streaming"),
assemblyJarName in assembly := "spark.jar",
assemblyMergeStrategy in assembly := {
case PathList("javax", "servlet", xs@_*) => MergeStrategy.first
case PathList("META-INF", "io.netty.versions.properties") => MergeStrategy.last
case PathList(ps@_*) if ps.last endsWith ".html" => MergeStrategy.first
case "application.conf" => MergeStrategy.concat
case "reference.conf" => MergeStrategy.concat
case m if m.toLowerCase.endsWith("manifest.mf") => MergeStrategy.discard
case m if m.toLowerCase.matches("meta-inf.*\\.sf$") => MergeStrategy.discard
case _ => MergeStrategy.first
},
test in assembly := {}
)
.enablePlugins(AssemblyPlugin)
This assembles just fine and includes (almost) everything I need. I only have one missing class in the scala.reflect library. Generally, the reflect library is included with the correct version and sbt run
does not have any problems.
The failing class of my code throwing Exception in thread "main" java.lang.NoClassDefFoundError: scala/reflect/api/JavaUniverse
imports scala.reflect.runtime.universe
which is a lazy val created like this in scala-reflect_2.11.8 (scala.reflect.runtime.package$.class)
package scala
package reflect
package object runtime {
lazy val universe: api.JavaUniverse = new runtime.JavaUniverse
...
Sbt now does not include the necessary class scala.reflect.api.JavaUniverse
even if I import it and declare the necessary lazy val as val uv: JavaUniverse = universe
in the failing class. Although sbt does include a class with the same name in a different package being: scala.reflect.runtime.JavaUniverse
.
Could this be a name conflict? Or is the problemin the package$.class
not defining package api
outside the package object?
Is there a way in sbt to manually declare a class to be included? Or any other workaround?
Any help is appreciated!
Aucun commentaire:
Enregistrer un commentaire