Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    David Kelly

    Hi @mtanski the README file for the sbt-assembly plugin isn't very clear about this for a new sbt user as I was when I first started using the plugin. However, after reading a lot about sbt (I recommend getting a copy of sbt in action) I was able to figure it out. You could try something like this (assuming you have a build.sbt file in the root of your project):

    // Project Definitions
    lazy val myproject = (project in file("."))
      .aggregate(core, subProjectOne, subProjectTwo)
      .settings(baseSettings ++ Seq(name := "my-project"))
    lazy val core = (project in file("core"))
    lazy val subProjectOne = (project in file("sub-project-one"))
    lazy val subProjectTwo = (project in file("sub-project-two"))
    // Gets current git commit ID
    lazy val gitCommit: String = sys.process.Process("git rev-parse HEAD").lines_!.head
    lazy val baseSettings = Seq(
      organization := "com.mycompany",
      scalaVersion := "2.11.7",
      version := "1.0-SNAPSHOT"
    // Settings common to most modules
    lazy val commonSettings = baseSettings ++ Seq(
      libraryDependencies ++= Seq(
        // put deps here
      assemblyMergeStrategy in assembly := {
        case PathList("META-INF", xs@_*) => MergeStrategy.discard
        case PathList("stuff", xs@_*) => MergeStrategy.discard
        case x => MergeStrategy.first
      assemblyJarName in assembly := s"${name.value}-${version.value}-${gitCommit.substring(0, 7)}.jar"
    // Settings for each project module
    lazy val coreSettings = commonSettings ++
      Seq(name := "core")
    lazy val subProjectOneSettings = commonSettings ++
      Seq(name := "sub-project-one")
    lazy val subProjectTwoSettings = commonSettings ++
      Seq(name := "sub-project-two")

    Hope this helps

    Milosz Tanski
    @kellydavid thanks, I was able to make it work this way
    David Kelly
    @mtanski No problem, thats great!
    I have a exclude jar @ assembly setting . However , still I see zookeeper class file insdie the final assembly jar
    excludedJars in assembly <<= (fullClasspath in assembly) map {
    _ filter { cp =>
    mergeStrategy in assembly := {
    case m if m.toLowerCase.endsWith("") =>
    case m if m.toLowerCase.matches("meta-inf.*\.sf$") =>
    case "reference.conf" => MergeStrategy.concat
    case _ => MergeStrategy.first
    Alexey Alekhin
    hi. is there a simple way to include given sources from the project in the assembly package? I like adding something besides sourceDirectories
    Alexey Alekhin
    I found a solution, just in case somebody else is interested: just change fullClasspath in assembly
    Justin Kaeser
    Is there a way in include only unmanaged dependencies in an assembly?
    Evan Chan
    Hi folks,
    Anybody know why I might get a ClassNotFound error?
    [error] (cli/*:assembly::assembledMappings) java.lang.ClassNotFoundException:$RuleCall
    Scala 2.10 / SBT 0.13.11 / assembly 0.14.3
    I have no idea because tests all pass with the same jar
    Alexey Alekhin

    Probably because you use a wrong version?

    For sbt 0.13.6+ ... version 0.14.4
    For older sbt 0.13.x, see sbt-assembly 0.11.2.

    Evan Chan
    0.14.3 is only slightly older and should still work.
    Moving to 0.14.4 did seem to fix it, but seemed to introduce another bug in prepended shell scripts.
    Alexey Alekhin
    I meant just the incompatibility with your old version of sbt. There was an important breaking change introduced in 0.13.5. Probably this is not related to your particular problems, but better to update sbt.
    Ryan Williams
    what's the easiest way to exclude my unmanagedJars (aka project's lib/ directory) from my assembly JAR?
    Ryan Williams

    well i'm holding my nose and going with

    assemblyExcludedJars in assembly := {
      (fullClasspath in assembly).value.filter {"/lib")

    for now

    Simon Leischnig
    Just wanted to give a quick thanks for the maintainers and @douglaz for mentioning the "include 'provided' dependencies back to run" on-liner into the README
    Hi, all... is anyone else running into serious problems using shading? It works fine on Mac OS X, but moving to another (CentOS) machine, the shading barely seems to work at all. It seems to change the paths of text and resource files properly, but not of class files. I saw some noise around about locale settings causing silent failures when shading, but wasn't able to affect the behavior with different locale settings.
    is there a way to run assembly such that it uses a cached version of the jar if no inputs have changed?
    I'm building an alternative sbt-proguard on top on sbt-assembly so it restricts proguard to only doing the optimisations / trimming rather than the jar building too
    but it means that every time I run my task, the assembly jar is being rebuilt, even though there are no changes
    I'm using FileFunction.cached around Set(assembly.value) but because assembly.value always creates the fat jar, it is not doing what I want.
    I see cacheOutput = true is the default, I've not changed this... so it doesn't appear to work as advertised
    seems the cache works but only after the jar is built TWICE. There is definitely something fishy going on
    anyone here?
    Ólafur Páll Geirsson
    Hi all! Is it expected that the packages sun and com.sun are included in the fatjar with default settings? By excluding those packages I was able to shave 8MB of our fat jar scalameta/scalameta#1794
    I suspect the reason this happens is because we set in our build.sbt, but I have not validated it yet.
    Ólafur Páll Geirsson
    using sbt-assembly 0.14.8
    Diego Pineda
    so im a bit frustrated right now. Im new to scala/sbt and i’m trying to add sbt-assembly plugin to build a jar with all my dependencies of my app
    im trying to add sbt-assembly plugin
    and no matter what i always get this error
    ive tried adding bintray resolvers
    moving the addSbtPlugin to build.sbt, plugins.sbt and assembly.sbt and the error is exactly the same
    ive run out of ideas
    the readme still has instructions for sbt 1.0-M6 and older
    do i just need to downgrade sbt and scala?
    Fritz Lorens
    Hey all, im trying out assembly with this sample project:
    i have successfully run sbt assembly
    but when i run the jar file i got the following error
    scala target/scala-2.12/play-chatroom-scala-example-assembly-2.6.x.jar
    Oops, cannot start the server.
    java.lang.RuntimeException: No application loader is configured. Please configure an application loader either using the play.application.loader configuration property, or by depending on a module that configures one. You can add the Guice support module by adding "libraryDependencies += guice" to your build.sbt.
            at scala.sys.package$.error(package.scala:30)
            at play.api.ApplicationLoader$.play$api$ApplicationLoader$$loaderNotFound(ApplicationLoader.scala:44)
            at play.api.ApplicationLoader$.apply(ApplicationLoader.scala:70)
            at play.core.server.ProdServerStart$.start(ProdServerStart.scala:50)
            at play.core.server.ProdServerStart$.main(ProdServerStart.scala:25)
            at play.core.server.ProdServerStart.main(ProdServerStart.scala)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(
            at java.lang.reflect.Method.invoke(
            at scala.reflect.internal.util.ScalaClassLoader.$anonfun$run$2(ScalaClassLoader.scala:106)
            at scala.reflect.internal.util.ScalaClassLoader.asContext(ScalaClassLoader.scala:41)
            at scala.reflect.internal.util.ScalaClassLoader.asContext$(ScalaClassLoader.scala:37)
            at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:132)
            at scala.reflect.internal.util.ScalaClassLoader$
    the project itself already depend on guice, so this error doesn't make any sense to me
    Nader Ghanbari
    Hi, has anyone managed to successfully shade a Scala library using sbt-assembly? It works for Java libraries (kafka-client e.g.) but not for akka-stream-kafka (a Scala library).
    Manu Zhang
    @naderghanbari Yes, can you share your build script ?
    Prateek Asthana
    Trying to create an uber jar using sbt-assembly and it mentioned applying MergeStrategy discard and renaming to few of them. I want to identify which are the files impacted and from which jar.
    sbt:dir> assembly
    [info] Updating ...
    [info] Done updating.
    [info] Including: scala-library-2.13.0.jar
    [info] Checking every *.class/*.jar file's SHA-1.
    [info] Merging files...
    [warn] Merging 'NOTICE' with strategy 'rename'
    [warn] Merging 'LICENSE' with strategy 'rename'
    [warn] Merging 'META-INF/MANIFEST.MF' with strategy 'discard'
    [warn] Strategy 'discard' was applied to a file
    [warn] Strategy 'rename' was applied to 2 files
    [info] SHA-1: 756de77bb6aa1ba19bec1ada02cc814c8432decc
    [info] Packaging /Users/asthanap/resources/gitRepositories/github/lambda-scala-terraform/target/scala-2.13/lambda-scala-terraform-assembly-0.1.jar ...
    [info] Done packaging.
    [success] Total time: 3 s, completed Jul 23, 2019 1:08:11 PM
    sbt:lambda-scala-terraform> assembly 
    [info] Including from cache: scala-library-2.13.0.jar
    [info] Checking every *.class/*.jar file's SHA-1.
    [info] Merging files...
    [warn] Merging 'META-INF/MANIFEST.MF' with strategy 'discard'
    [warn] Strategy 'discard' was applied to a file
    [info] Assembly up to date: /Users/asthanap/resources/gitRepositories/github/lambda-scala-terraform/target/scala-2.13/lambda-scala-terraform-assembly-0.1.jar
    [success] Total time: 1 s, completed Jul 23, 2019 1:09:47 PM
    Alessandro Vermeulen
    Is it possible to leave some dependency jars intact and don’t repackage them? Some of our dependencies rely on the file in their jar for meta-data.
    Hello, I have a project P and a library L, L is using a dependency Dv2 and P use Dv1. So P is not working when L is included. Is it possible to solve the issue by shading or building L in a way that Dv2 is not exposed ? I cannot change P. I am reading but i must be messing something because my project do not compile anymore.
    Hi !
    I'm trying to add a static resource folder to my fatjar (my webapp dist folder).
    I used managedResourceDirectories in Compile += baseDirectory.value / "webapp" / "dist" but it adds all resources to jar's root and I would like to put them into a webapp root level folder, so I can serve "./webapp" folder instead of "."
    Would you have any ideas ?
    Hello everyone!
    I want to change a simple asm code to c++ code.
    but I am facing problems...
    please help me
    mov eax,00000000
    in here transparency is address.

    I started this pr for adding support for renames in ScalaSignature when shading: sbt/sbt-assembly#393
    Currently it is only a WIP with some light testing. We plan to work on this after next week to get it in a mergable state.

    At the maintainers: can you take a look at it and give some initial feedback so we get a better idea of what needs to be done?
    There are some questions / discussion points in the PR description.

    Leandro Rodrigo Saad Cruz
    Any luck with sbt 1.3.x ?
    I'm pretty much finished with PR #393 . Does someone have time to review it?