scalasbtscala-3

Using Scala 3 to compile sbt's meta-build


It seems that, as of SBT 1.9.9, SBT meta-builds are still compiled with a Scala 2.12.18 variant of the compiler, by default. The downside of this is that all my Scala projects now use Scala 3, with its new syntax, and so I need to code my project in one version of Scala, yet maintain the build in a different version, with the older syntax.

I'm assuming that changing the Scala version used by the meta-build to Scala 3 will likely result in problems with SBT plugins that have not been compiled for Scala 2.13 or 3, etc.

Rather than going through the pain of verifying this, does anyone know if it is possible to compile the meta-build using Scala 3? Are there any plans to switch meta-builds over to Scala 3?


Solution

  • As of 2024-04, SBT 1.x still relies on Scala 2.12.

    The meta build (either your own code or plugins code) need to be written in Scala 2.12.

    As of 2024-04, Scala 3 support in SBT meta build is planned for SBT 2.x.

    See the following discussions:


    This is usually perfectly fine as you don't need very advanced Scala features in the meta build. If you do, this might indicate you've gone too far in the "build as code" IMHO.