Sbt sometimes takes a long time to compile (super long ..)

I am currently starting a fairly average project with Play Framework and sbt / scala. However, sometimes it takes a long time to compile a project, for example, 4 classes take about 120 seconds, while in most cases a project takes only a few seconds for everything! However, for the most part, it seems like it takes some time to collect a few things in my access to the database and services to create a bunch of files, creating private / public functions with smooth code without return codes.

Is there anything against this?

It just looks like sbt hangs at runtime:

[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...

and utils is a sbt subproject. Any idea why this took so long? and in most cases, when does this happen sometimes?

Here is my sbt file:

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)
+4

All Articles