Home > database >  Sbt assembly plugin generates an empty jar
Sbt assembly plugin generates an empty jar

Time:03-23

I always used maven and I'm learning SBT, but i have an issue: I'm using assembly plugin to generate a fat jar but with this configuration the produced jar contains only meta-inf folder and no jar (there isn't my src and neither dependencies jar)

ThisBuild / scalaVersion := "2.12.15"
ThisBuild / organization := "org.me"
ThisBuild / version := "0.1.0-SNAPSHOT"


Global / onChangedBuildSource := ReloadOnSourceChanges
lazy val root = (project in file("."))
  .settings(
    libraryDependencies  = "org.apache.phoenix" % "phoenix-core" % "4.14.0-HBase-1.3",
    libraryDependencies  = "org.apache.phoenix" % "phoenix-queryserver-client" % "6.0.0",
    assembly / assemblyMergeStrategy := (_ => MergeStrategy.first),
    assembly / mainClass := Some("org.me.Test"),
    assembly / assemblyJarName := "importer.jar"
  )

What am I doing wrong?

CodePudding user response:

To fix that I've replaced:
assembly / assemblyMergeStrategy := (_ => MergeStrategy.first

with

assemblyMergeStrategy in assembly := {
  case PathList("META-INF", xs @ _*) => MergeStrategy.discard
  case x => MergeStrategy.first
}
  • Related