abiratsis
abiratsis

Reputation: 7326

SBT is not generating bytecode class files for dependency

I have the next build.sbt file:

name := "olbico-spark-solution"

version := "0.2"
scalaVersion := "2.11.8"

resolvers += "Typesafe ivy repository" at "https://repo.typesafe.com/typesafe/ivy-releases/"
resolvers += "Typesafe maven repository" at "https://repo.typesafe.com/typesafe/maven-releases/"

mainClass in (Compile, run) := Some("com.olbico.spark.MergeManager")
mainClass in (Compile, packageBin) := Some("com.olbico.spark.MergeManager")

mappings in (Compile, packageBin) += {
  (baseDirectory.value / "src/main/config/current.conf") -> "config/current.conf"
}

libraryDependencies ++= {
  val sparkVer = "2.2.0"
  Seq(
    "org.apache.spark" %% "spark-core" % sparkVer % "provided" withSources(),
    "org.apache.spark" %% "spark-sql" % sparkVer % "provided" withSources(),
    "com.typesafe" % "config" % "1.3.1" withSources()
  )
}

What I am trying to achieve is to add an dependency to com.typesafe.config. With the current sbt configuration I would expect that the final bytecode would have the following structure:

~/test-spark-solution/target/scala-2.11/classes

 -com
     -olbico
          -spark
                JobManager$class.class
                JobManager.class
                ... more classes
     -typesafe
              -config
                    Optional.class
                    DefaultConfigLoadingStrategy.class
                    ... more classes

or at least to add a config-1.3.1.jar to the final package jar. Both solution are accepted by me although right now none of those is done. Under ~/olbico-spark-solution/target/scala-2.11/classes I have the following structure:

 -com
     -olbico
          -spark
                JobManager$class.class
                JobManager.class
                ... more classes

Also after packaging there is no config-1.3.1.jar included into the package jar. What is the best way to add a single dependency to my project with SBT?

Upvotes: 1

Views: 617

Answers (1)

Edmondo
Edmondo

Reputation: 20090

Plain packaging in the Java/Scala world is not meant to create a deployable executable but simply an archive of your module: you need to use SBT Assembly or SBT pack to get a fully deployable jar.

Upvotes: 3

Related Questions