从 5k 行 scala 代码中提取一个 50M 的 jar 文件是否合理?

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

到目前为止,我正在构建一个包含约 5k 行代码的 Scala 项目。我正在用 sbt assembly 创建一个 jar 文件。结果是 50M,这比我天真地预期的要大得多。这是一种合理的尺寸还是听起来有点臃肿?我只是希望得到一个粗略的指导。我的build.sbt如下。感谢:

  ...

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"
  )
}

是的,这是合理的。

当你用 assembly 制作一个 jar 时,它会添加所有已编译依赖项的内容。

您可以通过使用模块化依赖项使其更小,例如,如果您只使用 dynamo,则依赖 aws-dynamo jar 而不是所有 aws。如何完成或是否可以完成将因图书馆而异。