sbt / sbt-projectmatrix

MIT License
124 stars 14 forks source link

Partial dependsOn - is it possible? #56

Closed adamw closed 3 years ago

adamw commented 3 years ago

Would it be somehow possible to add an .dependsOn, but only for some Scala versions?

My use case is that I have subprojects, some of them built for scala 2 & 3, some for 2 only. Additionally, there's scala-2-only code in the scala-2+3 projects, which depends on scala-2-only projects ;)

Long story short, I'd like to add a projectMatrix(...).dependsOn(anotherProject), but only for selected Scala versions

eed3si9n commented 3 years ago

You can get hold of Project as follows where core is a matrix:

lazy val core12 = core.jvm("2.12.8")

Could you try:

lazy val core12 = core.jvm("2.12.8")
  .dependsOn(anotherProject)

and see if it works?

adamw commented 3 years ago

Yes, works great, thanks!

Initially I wanted to add the modified Project values as aggregates, but that didn't work. Turns out that specifying these projects e.g.:

lazy val openapiDocs: ProjectMatrix = ...
lazy val openapiDocs2_12 = openapiDocs.jvm(scala2_12).dependsOn(enumeratum.jvm(scala2_12))
lazy val openapiDocs2_13 = openapiDocs.jvm(scala2_13).dependsOn(enumeratum.jvm(scala2_13))

works exactly as I wanted: I have openapiDocs, openapiDocs2_12 and openapiDocs3 (as I assume, automatically generated from the matrix as it's not defined explicitly?) with the correct classpath.

Thanks again :)