Search code examples
scalajarsbtfilesizesbt-assembly

Is a 50M jar file reasonable from 5k lines of scala code?


I'm building a scala project with ~5k lines of code so far. I'm creating a jar file with sbt assembly. It's coming out to 50M, which is much larger than I'd naively expected. Is this a reasonable sort of size or does it sound suspiciously bloated? I'm just hoping for a rough guide. My build.sbt is as follows. Thanks:

  ...

scalaVersion  := "2.11.6" 

scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")

resolvers ++= Seq(
  "spray repo" at "http://repo.spray.io/",
  "Spray" at "http://repo.spray.io",      
  "Scalaz Bintray Repo" at "http://dl.bintray.com/scalaz/releases" 
)

libraryDependencies ++= {
  val akkaV = "2.3.10"
  val sprayV = "1.3.3"
  Seq(
    "io.spray"            %%   "spray-can"     % sprayV,
    "io.spray"            %%   "spray-routing-shapeless2" % sprayV,
    "io.spray"            %%   "spray-testkit" % sprayV,
    "io.argonaut"         %%   "argonaut"      % "6.0.4",
    "com.typesafe.akka"   %%   "akka-actor"    % akkaV,
    "com.typesafe.akka"   %%   "akka-slf4j"    % akkaV,
    "com.typesafe.akka"   %%   "akka-testkit"  % akkaV,
    "com.github.nscala-time" %% "nscala-time"  % "1.8.0",
    "com.wandoulabs.akka" %% "spray-websocket" % "0.1.4",

    "commons-codec"       % "commons-codec"    % "1.10",
    "com.amazonaws"       % "aws-java-sdk"     % "1.9.25",

    "com.typesafe.slick"  %% "slick" % "3.0.0",
    "mysql"               % "mysql-connector-java" % "5.1.35",

    "ch.qos.logback"      %   "logback-classic"   % "1.1.3",

    "io.reactivex"        %%  "rxscala"       % "0.24.1",

    "org.clapper"         %% "grizzled-slf4j" % "1.0.2"
  )
}

Solution

  • Yes, this is reasonable.

    When you make a jar with assembly it adds the contents of all your compiled dependencies.

    You could make this smaller by using modular dependencies, eg depend on the aws-dynamo jar instead of all of aws if dynamo is the only thing you use. How you accomplish this or if you can will vary by library.