Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ Cannot Import sbt Project

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
  MyProjName: syncing...
   dump project structure from sbt"

I have deleted the .idea directory and the the MyProjName/project/target directory. I did an sbt build from the command line, which worked. Then I started IntelliJ again and tried to import MyProjName/build.sbt as a project. I have also logged out/in. Did this several times. The import never progresses past this step.

I work behind a firewall, but I have checked my proxy settings, and they are correct and unchanged from the previous version (if this matters).

How can I troubleshoot / fix this?

The sbt version is 0.13.6. Scala plugin 2017.3.10.

From the log:

IDE: IntelliJ IDEA (build #IC-173.3727.127, 27 Nov 2017 09:32)
OS: Windows 7 (6.1, amd64) 
JRE: 1.8.0_152-release-1024-b6 (JetBrains s.r.o) 
JVM: 25.152-b6 (OpenJDK 64-Bit Server VM) 
like image 480
radumanolescu Avatar asked Dec 07 '17 14:12

radumanolescu


People also ask

Why sbt shell not showing in IntelliJ?

In Intellij 2018, under Preferences - Build, Execution, Deployment - Build Tools - sbt , check " Use sbt shell for build and import (requires sbt 0.13. 5+) ". Then restart Intellij. The sbt shell tool window tab will appear in the bottom pane (if not, select it from View - Tool Windows - sbt shell ).

How to import SBT changes in IntelliJ IDEA?

IntelliJ IDEA displays a nofication icon in the right part of the editor suggesting to Load sbt Changes made to the project ( Ctrl+Shift+O ). If you want to control the importing process of your project, you can manually trigger the action or configure the auto-reloading process. In the sbt tool window, right-click a linked project.

How do I run an sbt project in idea?

The first time you import an sbt project, the SBT Project Data To Import screen opens and asks you to confirm the import. IDEA opens the project. The status bar shows sbt downloading dependencies and refreshing the project: From the Run menu, select Run.

How do I import a project from SBT to eclipse?

From the Welcome Screen or File menu, select Open. Browse to and select the top-level folder of your sbt project, and click OK. The Import Project from SBT dialog opens. Enable use auto-import. For Download options, enable Sources and disable Javadocs and Sources for SBT and plugins. For Project SDK, verify the version (JDK 1.8).

How do I import a library from IntelliJ IDEA?

Specify a library you want to import. Put the caret at the unresolved package and press Alt+Enter. From the list of available intention actions, select Add sbt dependency. Follow the steps suggested in the wizard that opens and click Finish. IntelliJ IDEA downloads the artifact, adds the dependency to the build.sbt file and to the sbt tool window.


4 Answers

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:

enter image description here

like image 121
civic.LiLister Avatar answered Oct 22 '22 02:10

civic.LiLister


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.

like image 37
JPotts Avatar answered Oct 22 '22 02:10

JPotts


  • Open a terminal inside IDEA by pressing Alt F12 or use sbt shell
  • Run sbt - if it is first time it will take some time.
  • Run clean
  • Run compile - it will download dependencies you have in your project.
  • Close IDEA project (File -> Close Project) and open it again.

Note: if it asks to import in the right-bottom of the screen activate Enable auto-import, if you don't like to keep it enabled (like me) press Import, cancel the syncronyzation and then Refresh sbt project again. When you try to use import in the middle of a sync it gets stuck with dump project structure from sbt message.

The Refresh sbt project is located at this corner of the Build Sync window - highlighted below: Refresh sbt project

like image 35
Marcio Avatar answered Oct 22 '22 01:10

Marcio


I have not found a way to make this work in IntelliJ Idea CE 2017.3, so I have reverted to CE 2017.2.5

like image 44
radumanolescu Avatar answered Oct 22 '22 02:10

radumanolescu