quarkus: Can Scala 2 and Scala 2 Jackson be moved out of the BOM and into a Scala 2 Quarkiverse? (Scala is not ABI compatible)

Description

The short way of explaining this is that, unlike Java and Kotlin which are generally ABI compatible between versions, Scala’s ABI compatibility story is a bit of a mess.

The short of it is that:

  • Scala 3 is backwards compatible with Scala 2.13.x ONLY

But to complicate matters further, here’s an example:

  • Scala 3 Compiler 3.0.1 pulls in
  • Scala 3 Library 3 3.0.1 which then pulls in
  • Scala 2 Library 2.13.6

Now, if you have other Scala 2 dependencies in your build, here’s what happens:

  • Scala 2.12
    • Bad News Bearz
  • Scala 2.13 lower than the 2.13 the Scala 3 Compiler/Library uses
    • They will be reconciled to this lower version, which shouldn’t have any problems but may not be what you want

Because Quarkus has Scala 2.12 in it’s BOM, it causes a lot of problems.

  • The first is that, if you try to add Scala 3 Compiler for the quarkus-scala3 extension, it flat out breaks.
    • Why? Because Maven sees scala-library:2.12.13 in quarkus-bom and decides this is the version that ought to be used for the transitive dependency from the Scala 3 compiler.
    • This is an unusable combination of versions for Scala 3, no code will compile. It took me a few hours to figure out what was going on here (why the scala-library was getting force-set to 2.12 when Scala 2 needs 2.13.5/6)
  • So you need to manually set a Scala 2 library version that matches the one your Scala 3 version uses, and you need to be aware that you need to do this

Alternatively, if you’re using Gradle, you can do this:

dependencies {
    // scala3-compiler_3 resolve it's own scala3-library_3, and transitively scala-library (Scala 2)
    implementation "org.scala-lang:scala3-compiler_3:$Versions.SCALA3"

    // Quarkus comes with Scala 2 distributed in it's Bill-of-Materials unfortunately =/
    // It's Scala 2.12.13, which is not ABI compatible. If using Scala 3, we need to exclude this entirely
   implementation(enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}"))  {
         exclude group: 'org.scala-lang', module: 'scala-library'
    }

It’s the same sort of story with jackson-module-scala_2.12. Scala 3 is only compatible with jackson-module-scala_2.13 and jackson-module-scala_3 unfortunately 🙁

I know this may be somewhat complicated by this unfortunate sentence in the BOM:

        <!-- Scala is used by Kafka so we need to choose a compatible version -->
        <scala.version>2.12.13</scala.version>

Though I will note:

Changing the version to 2.13 would fix a LOT of these headaches due to 2.13 <-> 3.x binary compatibility

image

Implementation ideas

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 15 (14 by maintainers)

Most upvoted comments

Scala isn’t something I’ve seen used much so I’m not that concerned about “breaking” current user base.

Moving scala to quarkiverse wether it’s version 2 or 3 makes sense to me.

Wow bot, you tagged a LOT of the wrong people.

Sorry Justin, who I definitely know this has nothing to do with 😅