18

I have an sbt build that works when I run from the command line, but that Intellij does not like. My Intellij is running on Linux, its version is 14.1.4, my scala plugin is 1.5.2.

Intellij complains about my use of enablePlugins(JavaAppPackaging). The error is "Expression Type (DslEntry) must conform to Setting[_] in SBT file".

My project/build.properties file:

sbt.version=0.13.8

My project/plugins.sbt

addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.3")

And the first few lines of my build.sbt

enablePlugins(JavaAppPackaging)

organization := "org.bodhi"

name := "jar-patch"

version := "1.0"
Mustafa
  • 2,447
  • 23
  • 31
Christopher Helck
  • 1,130
  • 2
  • 8
  • 23

4 Answers4

3

The answer by @lifeGoGoGo on another thread Intellij IDEA and SBT syntax error works for me (on Ubuntu, setting the custom sbt-launcher.jar in global settings and project settings of IntelliJ IDEA - as sensibly answered by @Mustafa on this thread - wasn't enough, but then adding the "lazy val" tactic was enough). So for example, this worked for me in build.sbt (obviously you change your plugin-details to suit what you are doing, as this issue is caused by IntelliJ and not by the specific plugin you want to enable):

lazy val root = (project in file(".")).
  enablePlugins(ScalaJSPlugin).
  settings(
    name := "Scala.js Tutorial",
    scalaVersion := "2.11.7",
    version := "1.0"
  )
Community
  • 1
  • 1
2

IntelliJ uses a bundled SBT launcher which might be a different version than what you are running in the command line.

Since you already know that command line SBT works, you may point IntelliJ to use the command line SBT instead of the bundled one.

  1. Go to settings page for SBT at Settings -> Build, Execution, Deployment -> Build Tools -> SBT.
  2. In the launcher section, choose Custom and point to the SBT launcher installed in the OS. In Ubuntu, the default location is /usr/share/sbt-launcher-packaging/bin/sbt-launcher.jar
Mustafa
  • 2,447
  • 23
  • 31
  • 1
    Thanks. I did this and Intellij still complains. In the GUI the "enablePlugins()" has a red sqiggly line underneath it and has the same associated error message. As far as I can tell when I ask Intellig to build and run the program it works OK. Just the GUI has this annoying message. – Christopher Helck Jul 23 '15 at 01:40
  • 1
    @Mustafa : thanks this solved my problem. FYI for anyone else, I set it in global settings first and it didn't work, then on the project open I expanded the "Global SBT Settings" options and saw it was still set to "Bundled" so I set to custom there as well with "/usr/local/Cellar/sbt/0.13.8/libexec/sbt-launch.jar" and it finally worked. – alexP_Keaton Jul 29 '15 at 23:34
  • 1
    I have the same problem. Regardless setting custom `sbt-launch.jar` file in the IntelliJ settings error still appears. Running comman from CLI works fine, but IntelliJ can't build the project. I'm using SBT 0.13.8 and IntelliJ Ultimate 14.1.4 – Karol Janyst Jul 31 '15 at 10:23
  • Having the same problem but don't know where to find this file on mac? – marcin_koss Nov 17 '15 at 02:30
  • I'm not sure about Mac but it depends on how you installed sbt. If you have used a package manager such as homebrew, checking their docs might help finding out where it is installed. – Mustafa Nov 17 '15 at 18:18
  • 1
    @marcin_koss, try brew list sbt, it should tell you the path to the libexec directory containing the jar – Emil D Nov 28 '15 at 13:02
  • 1
    I am having the same issue, despite being on IntelliJ 15 now and with bundled 0.13.8 SBT. Tried to point to custom sbt 0.13.9 which I use from CLI, but the problem persists. – Yardena Jan 17 '16 at 10:30
0

@karol: I had the same problem. I solved by choosing again at the moment of opening the project /usr/share/sbt-launcher-packaging/bin/sbt-launcher.jar in "Import Project from SBT" -> Global SBT settings.

califano
  • 1
  • 1
0

The issue is due to how IntelliJ IDEA marks syntax errors, which may mark valid code red. This particular error will be fixed soon.

Justin Kaeser
  • 5,868
  • 27
  • 46