Search code examples
scalasbtcross-compiling

In sbt, how to make cross-version plugin to fail smoothly?


Assuming that if I used the sbt cross-version with may scala versions:

crossScalaVersions ++= List(
//  "2.13.6",
  "2.13.4",
  "2.13.3",
  "2.13.2",
  "2.13.1",
  "2.12.6",
  "2.12.7",
  "2.12.8",
  "2.12.9",
  "2.12.10",
  "2.12.11",
  "2.12.12",
  "2.12.13",
  "2.12.14",
)

Some of the versions are not compatible (this is an expected behaviour). When I run "sbt +test", the build process always fails early on the first compatibility error. Thus, it won't give 100% information on which versions are compatible.

Is there a way to instruct sbt to only throw a warning in this case, and keep trying all other versions, such that the programmer can get a compatibility matrix afterwards?

To give you more context of this question. The project which I'd like to try this is:

https://github.com/tek/splain

... with github actions as the primary CI for compatibility validation


Solution

  • You could use the sbt-projectmatrix plugin (https://github.com/sbt/sbt-projectmatrix) to define each version as a (sub)project.

    It is widely used to deal with complex scenarios involving cross versions.

    You would then have a quick view of which (sub)project are failing just by running sbt test.