IntelliJ Idea sbt managed source file
Asked Answered
A

1

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!

Abortion answered 30/5, 2014 at 15:18 Comment(4)
Which version of IntelliJ and Scala plugin are you using?Hairsplitter
IntelliJ Idea 13.0.3, not sure about the Scala plugin. Where can I check that?Cammi
Sadly, this is still a problem two years later. :(Dolphin
is it still a problem in 2017.1?Extradite
C
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.

Cottontail answered 16/6, 2014 at 19:39 Comment(3)
Also, see the answers to IntelliJ IDEA Report Highlighting error when using routes in Controller.Cottontail
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.Villada
same problem still here after 3 years and with idea 2019.3, sbt 1.3Take

© 2022 - 2024 — McMap. All rights reserved.