I'm writing a small Scala library. My library is dependent on two others - let's call them A and B. I would like to include A in my assembly's jar file, but not B, because 1) client code will always have a dependency on B, so it will always be present, and 2) B is a very large assembly.
Building with sbt assembly creates a fat jar with all dependencies. Building with sbt package creates a skinny jar with just my library's classes in it and nothing more. I'd like some kind of semi-skimmed jar that contains my classes and just the jar of dependency A.
I have had a look for potential modifications or additions to my Build.scala file to have SBT include just a specific dependency when it builds a jar, but I haven't managed to find anything to do. I'm not certain it's possible. Any help or guidance would be much appreciated.
If you are sure the B dependency will always be present at runtime, you can always mark B as provided.
libraryDependencies += "com.youcompany" %% "b-library" % "1.0" % "provided"
This means it will be included in the compile dependencies, but will be provided some other way at runtime, so there is no need to package it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With