sbt有时需要很长时间才能编译(超长..)

时间:2015-06-22 11:38:53

标签: scala playframework sbt slick

目前,我正在使用Play Framework和sbt / scala运行一个相当中等规模的项目。但是,有时需要很长时间来编译项目,比如4个类需要120秒,而大多数时候项目只需要几秒钟就可以完成所有事情! 然而,大多数情况下看起来在重构数据库访问和服务中的一些内容时需要一段时间,而创建没有返回代码的光滑代码的私有/公共函数。

还有什么可以对付这个吗?

看起来sbt在执行时挂起:

[info] Loading project definition from /Users/schmitch/projects/envisia/envisia-erp-loki/project
[info] Set current project to envisia-erp-loki (in build file:/Users/schmitch/projects/envisia/envisia-erp-loki/)
[info] Compiling 4 Scala sources to /Users/schmitch/projects/envisia/envisia-erp-loki/modules/utils/target/scala-2.11/classes...

而utils是一个sbt子项目。任何想法都是为什么需要这么长时间?而且大多数情况下有时只会发生?

这是我的sbt文件:

name := "envisia-erp-loki"

version := "1.0.1-SNAPSHOT"

lazy val utils = project in file("modules/utils")

lazy val migrator = (project in file("modules/migrator"))
  .enablePlugins(PlayScala).disablePlugins(PlayLayoutPlugin)
  .dependsOn(utils).aggregate(utils)

lazy val codegen = (project in file("modules/codegen"))
  .dependsOn(utils).aggregate(utils)

lazy val auth = (project in file("modules/auth"))
  .enablePlugins(PlayScala).disablePlugins(PlayLayoutPlugin)
  .dependsOn(utils).aggregate(utils)

lazy val pdfgen = project in file("modules/pdfgen")

lazy val root = (project in file("."))
  .enablePlugins(PlayScala, DebianPlugin)
  .dependsOn(utils).aggregate(utils)
  .dependsOn(auth).aggregate(auth)
  .dependsOn(pdfgen).aggregate(pdfgen)

scalaVersion in ThisBuild := "2.11.6"


libraryDependencies ++= Seq(
  filters,
  cache,
  ws,
  specs2 % Test,
  "com.typesafe.play" %% "play-slick" % "1.0.0",
  "com.typesafe.play" %% "play-slick-evolutions" % "1.0.0",
  "com.typesafe.play" %% "play-mailer" % "3.0.1",
  "org.elasticsearch" % "elasticsearch" % "1.5.2",
  "org.postgresql" % "postgresql" % "9.4-1201-jdbc41",
  "com.chuusai" %% "shapeless" % "2.2.0",
  "com.nulab-inc" %% "play2-oauth2-provider" % "0.15.0",
  "io.github.nremond" %% "pbkdf2-scala" % "0.4",
  "com.google.code.findbugs" % "jsr305" % "3.0.0"
)


resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"


resolvers ++= Seq(
  Resolver.sonatypeRepo("releases"),
  Resolver.sonatypeRepo("snapshots")
)

// Faster compilations:
sources in(Compile, doc) := Seq.empty

publishArtifact in(Compile, packageDoc) := false

// "com.googlecode.java-diff-utils" % "diffutils" % "1.3.0"

//pipelineStages := Seq(rjs)

// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator

JsEngineKeys.engineType := JsEngineKeys.EngineType.Node


// Do not add API Doc
sources in(Compile, doc) := Seq.empty

publishArtifact in(Compile, packageDoc) := false

// RpmPlugin
maintainer in Linux := "Christian Schmitt <c.schmitt@envisia.de>"

packageSummary in Linux := "Envisia ERP Server 3.0"

packageDescription := "This is the new Envisia ERP Server it will be as standalone as possible"

import com.typesafe.sbt.packager.archetypes.ServerLoader.Systemd

serverLoading in Debian := Systemd


scalacOptions in ThisBuild ++= Seq(
  "-target:jvm-1.8",
  "-encoding", "UTF-8",
  "-deprecation", // warning and location for usages of deprecated APIs
  "-feature", // warning and location for usages of features that should be imported explicitly
  "-unchecked", // additional warnings where generated code depends on assumptions
  "-Xlint", // recommended additional warnings
  "-Ywarn-adapted-args", // Warn if an argument list is modified to match the receiver
  "-Ywarn-value-discard", // Warn when non-Unit expression results are unused
  "-Ywarn-inaccessible",
  "-Ywarn-dead-code"
)

updateOptions in ThisBuild := updateOptions.value.withCachedResolution(true)

0 个答案:

没有答案