Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ doesn't seem to pickup certain sbt libraries, no code completion

I am using sbt console in my terminal to compile my scala/play project.

I am using intellij to edit my source code, basically using it just for getting some code completion and navigation etc.

For some reason certain libraries don't seem to load correctly. For example, I added elastic search to my Dependancies.scala file, reloaded sbt and everything compiles fine but for some reason IntelliJ doesn't pickup the jars correctly i.e. they are in red and there is no syntax completion.

How can I fix this? I tried shutting intellij down and restarting it but the problem remains.

I am using Intelli 13.1.3 (ultimate)

enter image description here

like image 355
Blankman Avatar asked Jun 11 '14 18:06

Blankman


2 Answers

If you use IDEA 13.x with the Scala plugin, you can directly import your SBT file (File -> Import Project...), and you don't need the sbt-idea plugin. If during the Import you select "Use auto-import", it will automatically sync any changes to your build.sbt file.

At one time I had the problem of IDEA getting confused and not autocompleting / labelling dependencies as errors. In that case, using File -> Invalidate Caches / Restart... fixed the problem. That hasn't happened to me in recent versions, though.

like image 80
Mario Camou Avatar answered Oct 23 '22 00:10

Mario Camou


When adding dependencies in general is good practice to regenerate idea xml configuration files (inside .idea and/or .idea_modules and the correlated .iml files), try adding this plugin and then use sbt gen-idea, or even better if you're using play you can simply use sbt idea with-sources=yes which ships with play as shown here.

Idea utilizes xml to store configurations, in fact if you look at them right now probably you won't find the jars/library you just added, simply because they are not automatically updated.

like image 42
Ende Neu Avatar answered Oct 23 '22 02:10

Ende Neu