by

Where communities thrive


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

    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)
      .disablePlugins(sbtassembly.AssemblyPlugin)
      .settings(baseSettings ++ Seq(name := "my-project"))
    
    lazy val core = (project in file("core"))
      .disablePlugins(sbtassembly.AssemblyPlugin)
      .settings(coreSettings)
    
    lazy val subProjectOne = (project in file("sub-project-one"))
      .dependsOn(core)
      .settings(subProjectOneSettings)
    
    lazy val subProjectTwo = (project in file("sub-project-two"))
      .dependsOn(core)
      .settings(subProjectTwoSettings)
    
    // 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
    @mtanski
    @kellydavid thanks, I was able to make it work this way
    David Kelly
    @kellydavid
    @mtanski No problem, thats great!
    bjdas
    @bjdas
    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 =>
    List("junit",
    "mockito",
    "org.apache.spark",
    "org.apache.zookeeper",
    "hadoop",
    "mesos",
    "jetty",
    "snappy",
    "curator",
    "parquet").exists(cp.data.getName.startsWith(_))
    }
    },
    mergeStrategy in assembly := {
    case m if m.toLowerCase.endsWith("manifest.mf") =>
    MergeStrategy.discard
    case m if m.toLowerCase.matches("meta-inf.*\.sf$") =>
    MergeStrategy.discard
    case "reference.conf" => MergeStrategy.concat
    case _ => MergeStrategy.first
    }
    )
    Alexey Alekhin
    @laughedelic
    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
    @laughedelic
    I found a solution, just in case somebody else is interested: just change fullClasspath in assembly
    Justin Kaeser
    @jastice
    Is there a way in include only unmanaged dependencies in an assembly?
    Evan Chan
    @velvia
    Hi folks,
    Anybody know why I might get a ClassNotFound error?
    [error] (cli/*:assembly::assembledMappings) java.lang.ClassNotFoundException: org.parboiled2.support.OpTreeContext$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
    @laughedelic

    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
    @velvia
    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
    @laughedelic
    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
    @ryan-williams
    what's the easiest way to exclude my unmanagedJars (aka project's lib/ directory) from my assembly JAR?
    Ryan Williams
    @ryan-williams

    well i'm holding my nose and going with

    assemblyExcludedJars in assembly := {
      (fullClasspath in assembly).value.filter {
        _.data.getParent.endsWith("/lib")
      }
    }

    for now

    Simon Leischnig
    @simlei
    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
    gehnaphore
    @gehnaphore
    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.
    Ghost
    @ghost~540393fe163965c9bc2018ce
    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
    Ghost
    @ghost~540393fe163965c9bc2018ce
    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
    Ghost
    @ghost~540393fe163965c9bc2018ce
    seems the cache works but only after the jar is built TWICE. There is definitely something fishy going on
    binyata
    @binyata
    hi
    anyone here?
    Ólafur Páll Geirsson
    @olafurpg
    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 javaHome.in(Compile) in our build.sbt, but I have not validated it yet.
    Ólafur Páll Geirsson
    @olafurpg
    using sbt-assembly 0.14.8
    Diego Pineda
    @nullhappens
    @nullhappens
    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 https://gist.github.com/nullhappens/a4d401a568191d20e14a1af8d5c5f16c
    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
    @lorensf
    Hey all, im trying out assembly with this sample project: https://github.com/playframework/play-scala-chatroom-example/tree/2.6.x
    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(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            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.run(ScalaClassLoader.scala:106)
            at scala.reflect.internal.util.ScalaClassLoader.run$(ScalaClassLoader.scala:98)
            at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:132)
            at scala.tools.nsc.CommonRunner.run(ObjectRunner.scala:28)
            at scala.tools.nsc.CommonRunner.run$(ObjectRunner.scala:27)
            at scala.tools.nsc.JarRunner$.run(MainGenericRunner.scala:21)
            at scala.tools.nsc.CommonRunner.runAndCatch(ObjectRunner.scala:35)
            at scala.tools.nsc.CommonRunner.runAndCatch$(ObjectRunner.scala:34)
            at scala.tools.nsc.JarRunner$.runAndCatch(MainGenericRunner.scala:21)
            at scala.tools.nsc.JarRunner$.runJar(MainGenericRunner.scala:33)
            at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:79)
            at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:92)
            at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:103)
            at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:108)
            at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
    the project itself already depend on guice, so this error doesn't make any sense to me
    Nader Ghanbari
    @naderghanbari
    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
    @manuzhang
    @naderghanbari Yes, can you share your build script ?
    Prateek Asthana
    @prateeka
    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
    @spockz
    Is it possible to leave some dependency jars intact and don’t repackage them? Some of our dependencies rely on the manifest.mf file in their jar for meta-data.
    Leo
    @leobenkel
    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 https://github.com/sbt/sbt-assembly#q-despite-the-concerned-friends-i-still-want-publish-fat-jars-what-advice-do-you-have but i must be messing something because my project do not compile anymore.
    mmenestret
    @mmenestret
    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 ?
    _fantasticDev_
    @SnakeGeneral
    @SnakeGeneral
    Hello everyone!
    I want to change a simple asm code to c++ code.
    but I am facing problems...
    please help me
    transparency:
    mov eax,00000000
    in here transparency is address.
    jeroentervoorde
    @jeroentervoorde

    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
    @leandrocruz
    Any luck with sbt 1.3.x ?
    jeroentervoorde
    @jeroentervoorde
    I'm pretty much finished with PR #393 . Does someone have time to review it?