20

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!

Eugene Yokota
  • 94,654
  • 45
  • 215
  • 319
Grega Kešpret
  • 11,827
  • 6
  • 39
  • 44

1 Answers1

7

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.

Community
  • 1
  • 1
Michael Ahlers
  • 616
  • 7
  • 21
  • Also, see the answers to [_IntelliJ IDEA Report Highlighting error when using routes in Controller_](http://stackoverflow.com/a/20398590/700420). – Michael Ahlers Jun 17 '14 at 00:40
  • 2
    I also had to remove the exclusion on `/target` in a subproject to get this to work. Then I had to unmark `src_managed/main` as sources, and then mark `src_managed/main/java` as sources. – mikebridge Jul 21 '16 at 02:28
  • same problem still here after 3 years and with idea 2019.3, sbt 1.3 – yeluolei Jan 21 '20 at 05:07