Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does IDEA report errors for build.sbt in a new sbt project?

I'm running IntelliJ 13.1.5 community edition. I've got JDK, Scala, SBT installed. The JAVA_HOME, JDK_HOME, SCALA_HOME and SBT_HOME variables are set. If I create a new SBT project, after initial sbt refresh, I get this:

intellij error

The thing compiles and runs fine, even if I add dependencies, but the file itself shows tonnes of errors. F4 settings show empty SBT module stuff:

empty module

I then installed https://github.com/mpeltonen/sbt-idea and ran sbt gen-idea in the project folder. This created a bunch of files, and reloading the project, the reds in the sbt file went away.

This is on my laptop. However, on my work machine, simply creating a new project works fine, and the sbt file isn't filled with red. Can't seem to figure out how that machine's different. Any pointers on how to resolve this annoying issue?

like image 774
ashic Avatar asked Oct 07 '14 22:10

ashic


People also ask

How compile sbt project in Intellij?

Press Ctrl+Alt+S to open the IDE settings and select Build, Execution, Deployment | Build Tools | sbt. In the sbt projects section, select a project for which you want to configure build actions. In the sbt shell section, select the builds option. Click OK to save the changes.

What is provided in build sbt?

In that case, we can mark that dependency as “provided” in our build. sbt file. The “provided” keyword indicates that the dependency is provided by the runtime, so there's no need to include it in the JAR file. When using sbt-assembly, we may encounter an error caused by the default deduplicate merge strategy.

Which is the correct way to add dependencies in sbt file?

Library dependencies can be added in two ways: unmanaged dependencies are jars dropped into the lib directory. managed dependencies are configured in the build definition and downloaded automatically from repositories.


2 Answers

I was also getting highlighted errors in all of the build.sbt file. What fixed it was to select to Download "Sources for SBT and plugins" in the Import Project from SBT window.

like image 191
Miguel Reyes Avatar answered Sep 23 '22 00:09

Miguel Reyes


In case IntelliJ IDEA struggles a bit with caching, try the first and if still not working the second should definitely do the trick:

  • File -> Invalidate cache and restart
  • Close IDEA, delete .idea, re-import your project
like image 32
stackoverflowed Avatar answered Sep 26 '22 00:09

stackoverflowed