Search code examples
sbtakkasbt-assembly

Excluding a dependency in creating fat jar using SBT


I am writing a akka application. While creating far jar of application , I dont want scala libraries to be packaged with the jar. My build.sbt looks as follows:

lazy val root = (project in file(".")).
  settings(
    name :="akka-app",
    version :="1.0",
    scalaVersion :="2.10.4",
    mainClass in Compile := Some("sample.hello.HelloWorld")            
  )

libraryDependencies ++= Seq(
  "com.typesafe.akka" %% "akka-actor" % "2.3.4" % "provided",
  "com.typesafe" % "config" % "1.2.1"

)

// META-INF discarding
mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
   {   
    case PathList("META-INF", xs @ _*) => MergeStrategy.discard
    case x => MergeStrategy.first
   }   
}

But this sbt packages scala with jar. I want only com.typesafe.config library to be present in the jar. Any solution how to achieve this?


Solution

  • You can exclude Scala by modifying the option in the assemblyOption setting:

    assemblyOption in assembly := 
      (assemblyOption in assembly).value.copy(includeScala = false)