I think it could be a problem that appeared in new versions, and can't be resolved as old versions, I got a Play Java project with sbt-buildinfo
plugin the problem is really common is that IntelliJ keep saying it can't resolve that symbol
And here is the file:
Some solutions can be found IntelliJ Idea sbt managed source file and here sbt-buildinfo generated object cannot be referenced but none of the solutions provided were helpful for me:
The really strange thing is if I "Unmark the directory as a generated source" and then move that BuildInfo.scala
file to the package folder manually to buildpkg
(my custom package) instead of sbt-buildinfo
package, IntelliJ see that file, but this change is useless because the file will be generated again and all changes will be discarded:
Here is my build.sbt:
lazy val root = (project in file(".")).enablePlugins(PlayJava, BuildInfoPlugin)
.settings(
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion, buildInfoBuildNumber,
"hostname" -> java.net.InetAddress.getLocalHost.getHostName,
"gitHash" -> sys.env.getOrElse("BITBUCKET_COMMIT", "No BITBUCKET_COMMIT set")
),
buildInfoPackage := "buildpkg",
buildInfoOptions += BuildInfoOption.ToJson,
buildInfoOptions += BuildInfoOption.BuildTime
)
scalaVersion := "2.12.3"
and my plugins.sbt :
// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.5")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0")
So what I'm missing, what the solution for this
In the sbt settings in IntelliJ, enable the settings "Use sbt shell for build and import", since the sources are generated only when sbt runs the build.
IntelliJ will currently only correctly update generated sources if they are in the correct package directory. For sbt-buildinfo, add the setting
buildInfoUsePackageAsPath := true
to your build.sbt
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With