Ask Your Question

Revision history [back]

Yes, it is possible to use build.sbt with multiple Scala versions. This is usually done using cross-building or cross-compilation, where the same codebase is compiled against multiple Scala versions to produce multiple artifacts.

To specify multiple Scala versions in build.sbt, you can use the crossScalaVersions setting. For example:

scalaVersion := "2.12.10"

crossScalaVersions := Seq("2.11.12", "2.12.10", "2.13.1")

With this configuration, sbt will compile your code against all three specified Scala versions, and produce a separate artifact for each version.

You can also use conditional configuration or macros to write code that is compatible with multiple Scala versions. This usually involves using build tools like sbt or Maven to generate different versions of the code depending on the Scala version.