Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij IDEA and SBT syntax error

I am newbie in scala and SBT
I started using IDEA with SBT and faced unclear error (Expression type DslEntry must conform to Def.SettingsDefinition in SBT file)
enter image description here
It's very simple empty test project with jetty plugin (example taken from plugin site)

here's plugins.sbt source:

logLevel := Level.Warn

addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "2.1.0")

This error is present only in IDEA GUI. If I compile project - all fine. from console - all fine. But I do not like when something does not work properly

I tried to download last version of SBT and set path to it in global IDEA properties - the problem persists.

I downloaded last intellij IDEA EAP with last version of scala plugin, sbt plugin and another plugins - the problem persists.

Can anyone help to solve this issue?
Thanks

like image 518
Alexandr Avatar asked Dec 21 '15 21:12

Alexandr


People also ask

How do I get sbt tab in IntelliJ?

Click sbt on the right sidebar to open the tool window. The tool window displays the sbt linked projects, their tasks, dependencies, and all changes made to the underlying build.

Where is Plugins sbt in IntelliJ?

IntelliJ plugin can be found here http://confluence.jetbrains.com/display/SCA/Scala+Plugin+for+IntelliJ+IDEA or can be installed directoly from within the IDE using Settings -> Plugins dialog. Afterwards one can just do File -> New Project -> Scala -> SBT based.


1 Answers

Try this:

lazy val root = (project in file(".")).
  enablePlugins(JettyPlugin).
  settings(
    name := "test",
    scalaVersion := "2.11.7",
    version := "1.0"
  )

Updates: The followings are what I know:

The error comes from intellij's sbt plugin https://github.com/JetBrains/intellij-sbt/blob/master/idea-plugin/src/main/scala/org/jetbrains/sbt/language/SbtAnnotator.scala#L41.

The return type of (project in file(".")). enablePlugins(JettyPlugin) is Project. It is acceptable by sbt plugin.

However, if you use standalone enablePlugins(JettyPlugin), the return type is different, and it becomes DslEntry which makes the sbt plugin unhappy. Another way to workaround with that is simply to consume the return type of enablePlugins. For example:

val foo = enablePlugins(JettyPlugin)
like image 123
SexyNerd Avatar answered Oct 05 '22 22:10

SexyNerd