IntelliJ SBT requires a very long update

I have a rather large project (15+ subprojects) that has many external dependencies. When I change at least one line in build.sbt and then hit the update, IntelliJ continues to resolve various dependencies for a very long time (30 + minute).

Is it supposed to be so slow? Using sbt from the command line takes no more than 30 seconds.

I use -

 Macbook pro mid 2015 with 16 GB ram IntelliJ IDEA Ultimate 2017.2.5 sbt 0.13.13 scala 2.11.11 
+10
scala intellij-idea sbt
source share
4 answers

I have included the SBT shell inside IntelliJ, as suggested by @ y.bedrov, and now the update is as fast as on the command line!

Settings> Build, Run, Deploy> Build Tools> SBT> check the box "Use SBT wrapper for assembly and import".

+3
source share

One thing that can help is cached dependency resolution, which is available with sbt 0.13.7. Take a look here: http://www.scala-sbt.org/1.0/docs/Cached-Resolution.html , but basically you need to enable the following settings for all projects in your assembly:

 updateOptions := updateOptions.value.withCachedResolution(true) 

Thanks to this setup, I was able to reduce the IntelliJ project update time from 15 to 3 minutes. Still not ideal, but more manageable.

There are some warnings, as this is an experimental setup, they are described on this page. Essentially, if you have SNAPSHOT dependencies, enabling this will only make things worse, so keep that in mind.

+6
source share

The answers from Kakaji and Haspemulator helped me import up to ~ 3 minutes when building the ~ 40 project. In addition to this, I found out that most of the time in IntelliJ SBT was spent importing dependencies on Ivy as part of the updateClassifiers .

This happens every time you import, if the "Library Sources" checkbox is enabled when importing a project. I expect this to be slower if you also check out 'sbt sources', because that means more libraries will be allowed.

One way to speed up updateClassifiers is to use coursier to resolve dependencies. I just added the following line to project / plugins.sbt and now it is imported after ~ 1 minute.

 addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.1") 

You can learn more about updateClassifiers slow at https://github.com/sbt/sbt/issues/1930

+4
source share

I use the combination of 2 above (- Settings> Build, Run, Deploy> Build Tools> SBT> Check "Use SBT wrapper for assembly and import" - coursier

with the following global build.sbt:

  // file: ~/.sbt/0.13/plugins/build.sbt // purpose: add jar utils useful for development, but not wanted to projects' build.sbt // much better depts resolvement and fetching // usage: sbt update // https://github.com/coursier/coursier#why resolvers += Resolver.sonatypeRepo("snapshots") addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.1.0-SNAPSHOT") // enable this one if you want to use the local artifacts in your local repo's // ~/.ivy2/local/ // ~/.ivy2/cache/ // instead of the remote ones // updateOptions := updateOptions.value.withLatestSnapshots(false) resolvers ++= Seq( "typesafe" at "https://dl.bintray.com/typesafe/ivy-releases/", "Maven External Releases" at "https://artifactory-espoo1.ext.net.nokia.com/artifactory/public-maven-remotes/" ) // eof file: ~/.sbt/0.13/plugins/build.sbt 
0
source share

All Articles