简体   繁体   English

Intellij sbt sbt-native-packager和enablePlugins错误

[英]Intellij sbt sbt-native-packager and enablePlugins error

I have an sbt build that works when I run from the command line, but that Intellij does not like. 我有一个sbt构建,当我从命令行运行,但Intellij不喜欢。 My Intellij is running on Linux, its version is 14.1.4, my scala plugin is 1.5.2. 我的Intellij在Linux上运行,它的版本是14.1.4,我的scala插件是1.5.2。

Intellij complains about my use of enablePlugins(JavaAppPackaging). Intellij抱怨我使用了enablePlugins(JavaAppPackaging)。 The error is "Expression Type (DslEntry) must conform to Setting[_] in SBT file". 错误是“表达式类型(DslEntry)必须符合SBT文件中的设置[_]”。

My project/build.properties file: 我的project / build.properties文件:

sbt.version=0.13.8

My project/plugins.sbt 我的项目/ plugins.sbt

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

And the first few lines of my build.sbt 还有我的build.sbt的前几行

enablePlugins(JavaAppPackaging)

organization := "org.bodhi"

name := "jar-patch"

version := "1.0"

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). @lifeGoGoGo在另一个线程上的答案Intellij IDEA和SBT语法错误适用于我(在Ubuntu上,在IntelliJ IDEA的全局设置和项目设置中设置自定义sbt-launcher.jar - 由@Mustafa在此线程上明智地回答 - wasn够了,但是加上“懒惰的”战术就足够了。 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): 例如,这对我在build.sbt中起作用(显然你改变你的插件细节以适应你正在做的事情,因为这个问题是由IntelliJ而不是你想要启用的特定插件引起的):

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

IntelliJ uses a bundled SBT launcher which might be a different version than what you are running in the command line. IntelliJ使用捆绑的SBT启动程序,它可能与您在命令行中运行的版本不同。

Since you already know that command line SBT works, you may point IntelliJ to use the command line SBT instead of the bundled one. 由于您已经知道命令行SBT有效,因此您可以指向IntelliJ使用命令行SBT而不是捆绑的命令行。

  1. Go to settings page for SBT at Settings -> Build, Execution, Deployment -> Build Tools -> SBT . Settings -> Build, Execution, Deployment -> Build Tools -> SBT转到SBT的设置页面。
  2. In the launcher section, choose Custom and point to the SBT launcher installed in the OS. 在启动器部分中,选择“ Custom并指向操作系统中安装的SBT启动程序。 In Ubuntu, the default location is /usr/share/sbt-launcher-packaging/bin/sbt-launcher.jar 在Ubuntu中,默认位置是/usr/share/sbt-launcher-packaging/bin/sbt-launcher.jar

@karol: I had the same problem. @karol:我遇到了同样的问题。 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. 我在“从SBT导入项目” - >全局SBT设置中打开项目/usr/share/sbt-launcher-packaging/bin/sbt-launcher.jar时再次选择解决了。

The issue is due to how IntelliJ IDEA marks syntax errors, which may mark valid code red. 问题是由于IntelliJ IDEA如何标记语法错误,这可能会将有效代码标记为红色。 This particular error will be fixed soon. 这个特殊的错误很快就会解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM