I use sbt-projectmatrix for a project like this:
// project/plugins.sbt
addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.8.0")
// build.sbt
val foo = projectMatrix
.jvmPlatform(Seq("2.13.6", "2.12.15"))
.settings(
Compile / unmanagedSourceDirectories += (ThisBuild / baseDirectory).value / "shared"
)
// foo/src/main/scala/Foo.scala
object Foo {
val s = "foo"
def sharedS = Shared.s
}
// shared/Shared.scala
object Shared {
val s = "shared"
def fooS = Foo.s
}
When I import into Intellij, it complain:
Duplicate content roots detected: Path [/tmp/bug] of module [bug] was removed from modules [shared-sources]
Then Intellij don't know Shared.s in Foo.scala (it mark Shared red with error "Cannnot resolve symbol Shared") and don't know Foo.s in Shared.scala.
Any workaround please?
Extra info:
In my real project, I have other val bar = projectMatrix.. and foo and bar share some scala source which I put in shared folder
EDIT: Sorry. I have just found that this issue don't related to sbt-projectmatrix: Replace projectMatrix by project in build.sbt => same problem.