IntelliJ Cannot Import sbt Project

前端 未结 14 1899
Happy的楠姐
Happy的楠姐 2021-01-29 23:14

I have upgraded IntelliJ to version CE 2017.3 from a CE 2017.2.5, and now I cannot build my sbt project. The build gets stuck on the first step:

\"Build: sync
           


        
相关标签:
14条回答
  • 2021-01-29 23:48

    The only way I could work around this was by running sbt clean compile in the SBT console/cmd line first, then refreshing the SBT project in IntelliJ.

    0 讨论(0)
  • 2021-01-29 23:50

    Custom SBT version works for me.

    IntelliJ IDEA Preferences -> Build,Execution,Deployment -> Build Tools -> sbt -> Launcher

    Choose Custom

    custom sbt screenshot

    0 讨论(0)
  • 2021-01-29 23:52

    I solved the sync issue following info here: https://youtrack.jetbrains.com/issue/SCL-13024

    Key info is "It seems that sbt is trying to re-resolve 'sources' and 'docs' for sbt plugins that are not available at all. If properties to download "Library sources" and "sbt sources" are disabled, then time to dump the structure is reduced from 'forever' to less than 1 minute."

    That is , in IntelliJ IDEA, clear the check box "Library sources" under "Project level settings" for Build Tools sbt in IDEA preferences. As shown in image below:

    0 讨论(0)
  • 2021-01-29 23:52

    IntelliJ appears to limit the efficiency of the already slow sbt update. I recommend using sbt-coursier instead. It was written specifically to improve dependency update time, and on one large project I'm involved in it improved dependency update time by about 2 orders of magnitude.

    1. Uncheck "Use auto-import" in Preferences > Build, Execution, Deployment > Build Tools > sbt to prevent IntelliJ from auto updating imports on its own

    1. Add addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.3") to your project's build.sbt file
      • Or install it globally in ~/.sbt/1.0/plugins/build.sbt
    2. Run sbt update on the command line

    If you see [error] java.lang.NoClassDefFoundError: org/vafer/jdeb/Console, then add the following to ~/.sbt/1.0/sbt-coursier.sbt.

    import coursier.Keys._
    classpathTypes += "maven-plugin"
    

    See coursier issue #450 for more information about that error.

    1. (Optional) Re-enable auto-import from step 1, as subsequent transactional dependency updates may be faster.
    0 讨论(0)
  • 2021-01-29 23:53

    I was also facing this issue. Below two configurations worked for me. I tried to confirm this setting in many new sbt projects, for all it worked.

    (1) uncheck "Library sources" under "Project level settings" for Build Tools sbt in IDEA preferences (2) -Dhttp.nonProxyHosts="host1|host2" option in File > Settings > Build, Excution, Deployment > sbt > VM parameters

    0 讨论(0)
  • 2021-01-29 23:57

    What worked for me was to increase the memory for SBT inside IntelliJ. On my Mac: preference -> Build, Execution, Depoyment -> sbt then change "Maximum heap size" from 768MB to 2048MB and then everything was successfully imported after few minutes.

    0 讨论(0)
提交回复
热议问题