sbt / sbt-projectmatrix

MIT License
124 stars 14 forks source link

Document how to use this plugin effectively with IntelliJ #60

Open kflorence opened 3 years ago

kflorence commented 3 years ago

I love what this plugin provides, but I'm struggling to use it with IntelliJ. We have it set up here https://github.com/jbwheatley/pact4s to provide support for Java 8 and Java 11, however, when I load the project in IntelliJ it will load the Java 8 dependencies everywhere, which makes development against Java 11 difficult. Are there workarounds or settings that make IntelliJ support better?

I see: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360008744360-Configuring-the-Scala-plugin-so-that-only-a-subset-of-projects-is-imported

Perhaps we need to configure "views" for the project, where we can select one view at a time during development? In any case, it would be nice to document this so it's easier for people to use this plugin.

ohze commented 3 years ago

I have other simple-and-common use case: unmanagedSourceDirectories don't work with Intellij (question on stackoverflow)

// 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
}

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 😢

EDIT: Sorry. I have just found that this issue don't related to sbt-projectmatrix: Replace projectMatrix by project in build.sbt => same problem

nafg commented 2 years ago

I'm also having an issue with unmanagedSourceDirectories not being recognized by IntelliJ, I'm pretty sure only since I switched to sbt-projectmatrix