IntelliJ Idea sbt managed source file

邮差的信 提交于 2019-12-18 14:16:32

问题


I am using sbt-buildinfo plugin that generates Scala source from my build definitions, allowing me to reference project name, version, etc. from my Scala code.

It does this by generating a file BuiltInfo.scala with the following contents:

package hello

case object BuildInfo {
  val name = "helloworld"
  val version = "0.1-SNAPSHOT"
  val scalaVersion = "2.10.3"
  val sbtVersion = "0.13.2"
}

in

target/scala-2.10/src_managed/main/sbt-buildinfo/BuildInfo.scala.

Everything compiles and I can reference those vals.

However, IntelliJ Idea doesn't recognize BuildInfo.scala as a managed source file, so that it would stop showing me errors. Any idea how to do that?

Thanks!


回答1:


Grega, are you working in a Play Framework project? Or do you have any SBT sub-projects? I don't have a complete answer, but may have a lead.

This same problem shows up in my IDEA projects when using sbt-buildinfo and sbt-scalaxb. Frustratingly, it has worked intermittently—usually after lots of tinkering around, but inexplicably stops.

I wound up digging a bit deeper (and eventually issued bug report SCL-7182 to JetBrains), and noticed the root cause was having a sub-project. When present, IDEA doesn't correctly identify src_managed for the root project, but does for the sub-project.

A work-around, for now, is to manually add the correct src_managed directory to your project's sources using the Project Structure dialog.

For reference, I'm running version 0.38.437 of the Scala plugin on IntelliJ IDEA 13.1.3.



来源:https://stackoverflow.com/questions/23957955/intellij-idea-sbt-managed-source-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!