Intellij IDEA和SBT语法错误 [英] Intellij IDEA and SBT syntax error

查看:278
本文介绍了Intellij IDEA和SBT语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是scala和SBT的新手

我开始在SBT中使用IDEA并面临不明确的错误(表达式类型DslEntry必须符合SBT文件中的Def.SettingsDefinition)



这是一个非常简单的带有jetty插件的空测试项目(例子来自插件网站)

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)

It's very simple empty test project with jetty plugin (example taken from plugin site)

这里的插件。 sbt source:

here's plugins.sbt source:

logLevel := Level.Warn

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

此错误仅出现在IDEA GUI中。如果我编译项目 - 一切都很好。从控制台 - 一切都很好。
但我不喜欢什么东西不能正常工作

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

我试图下载最新版本的SBT并在全局IDEA属性中设置路径 - 问题坚持下去。

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

我最后一个版本的scala插件,sbt插件和另一个插件下载了最后一个intellij IDEA EAP - 问题仍然存在。

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

推荐答案

试试这个:

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:

错误来自intellij的sbt插件 https://github.com/JetBrains/intellij-sbt/blob/master/idea-plugin/src/main/scala/org/jetbrains/sbt/language/SbtAnnotator。斯卡拉#L41

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.

的返回类型(项目在文件中(。))。
enablePlugins(JettyPlugin)
Project 。它可以被sbt插件接受。

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

但是,如果你使用独立的 enablePlugins(JettyPlugin),返回类型是不同,它变成 DslEntry ,这使得sbt插件不满意。另一种解决方法是简单地使用返回类型 enablePlugins 。例如:

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)

这篇关于Intellij IDEA和SBT语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆