diff --git a/README.md b/README.md index fc16396..bade6c3 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ - [Functional HTTP routes (Vert.x handlers)](#functional-http-routes-vertx-handlers) - [Contributors ✨](#contributors-) -## Introduction +## Introduction This extension provides support for Scala 3 in Quarkus. @@ -51,43 +51,23 @@ repositories { } VERSIONS = [ - QUARKUS_SCALA3: "0.0.1", - SCALA3 : "3.1.0", - SCALA_LIBRARY : "2.13.6", - // Scala Jackson at time of writing doesn't support Scala 3 Enum's natively. It requires another library. - // That library doesn't support same version of Jackson that Quarkus BOM uses (2.12.5), so this is the best compromise - // https://search.maven.org/artifact/com.github.pjfanning/jackson-module-scala3-enum_3/2.12.3/jar - JACKSON : "2.12.3" + QUARKUS: "3.10.0", + QUARKUS_SCALA3: "1.0.0", + SCALA3 : "3.3.3", ] dependencies { + implementation enforcedPlatform("io.quarkus.platform:quarkus-bom:${VERSIONS.QUARKUS}") implementation "io.quarkiverse.scala:quarkus-scala3:${VERSIONS.QUARKUS_SCALA3}" - implementation("org.scala-lang:scala3-compiler_3") { - version { - strictly VERSIONS.SCALA3 - } - } - implementation("org.scala-lang:scala3-library_3") { - version { - strictly VERSIONS.SCALA3 - } - } - implementation("org.scala-lang:scala-library") { - version { - strictly VERSIONS.SCALA_LIBRARY - } - } + implementation "org.scala-lang:scala3-library_3:${VERSIONS.SCALA3}" + 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 -- With Scala 3, we need to exclude this entirely - implementation(enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")) { - exclude group: 'org.scala-lang', module: 'scala-library' - } implementation "io.quarkus:quarkus-arc" implementation "io.quarkus:quarkus-resteasy-reactive" - implementation "com.fasterxml.jackson.module:jackson-module-scala_3:${VERSIONS.JACKSON}" - implementation "com.github.pjfanning:jackson-module-scala3-enum_3:${VERSIONS.JACKSON}" + implementation "io.quarkus:quarkus-jackson" + implementation "io.quarkus:quarkus-rest-jackson" + implementation "com.fasterxml.jackson.module:jackson-module-scala_3" testImplementation "io.quarkus:quarkus-junit5" testImplementation "io.rest-assured:rest-assured" @@ -97,31 +77,24 @@ group = "org.acme" version = "1.0.0-SNAPSHOT" java { - // Set to 17 for performance reasons, feel free to change to 11 or 8 - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } tasks.withType(ScalaCompile) { scalaCompileOptions.additionalParameters = [ - "-feature", // Emit warnings and locations for features that should be imported explicitly - "-explain", // Explain (type) errors in more detail - "-Ysafe-init", // Ensure safe initialization of objects (prevent null object init) - "-Yrequire-targetName", // Warn if an operator is defined without a @targetName annotation - // "-Yexplicit-nulls", // Make reference types non-nullable. Nullable types can be expressed with unions: e.g. String|Null. - - // I am unsure if this is required for proper tooling to work. Metals/IntelliJ may already cover this. - "-Xsemanticdb", // Store information in SemanticDB + "-feature", + "-Wunused:all", ] } compileJava { - options.encoding = 'UTF-8' - options.compilerArgs << '-parameters' + options.encoding = "UTF-8" + options.compilerArgs << "-parameters" } compileTestJava { - options.encoding = 'UTF-8' + options.encoding = "UTF-8" } ``` @@ -131,43 +104,40 @@ If you want to use this extension, you need to add the `io.quarkiverse.scala:qua In your `pom.xml` file, add: ```xml - - io.quarkiverse.scala - quarkus-scala3 - 0.0.1 - + +... + + io.quarkiverse.scala + quarkus-scala3 + 0.0.1 + +... ``` -Then, you will need to install the Scala 3 compiler, the Scala Maven plugin, and to fix an odd bug with the way that the Scala 3 compiler Maven dependencies are resolved. - -Due to Scala 2 version in upstream `Quarkus BOM`, the wrong version of `scala-library` (a transitive dependency: `scala3-compiler_3` -> `scala3-library_3` -> `scala-library`) is resolved. - -This causes binary incompatibilities -- and Scala to break. In order to fix this, you just need to manually align the version of `scala-library` to the one listed as used by the version of `scala3-library_3` that's the same as the `scala3-compiler_3` version. - -So for `scala3-compiler_3` = `3.0.0`, then `scala3-library_3` = `3.0.0`, and we check the `scala-library` version it uses: -- https://mvnrepository.com/artifact/org.scala-lang/scala3-library_3/3.0.0 - -Here, we can see that it was compiled with `2.13.5` in it's dependencies. So that's what we set in ours: +Then, you will need to add the Scala 3 compiler and library and the Scala Maven plugin: ```xml - 4.5.3 - 3.1.0 - 2.13.6 + 4.9.1 + 3.3.3 - org.scala-lang - scala3-compiler_3 - ${scala.version} + io.quarkiverse.scala + quarkus-scala3 + 1.0.0 + + + org.scala-lang + scala3-library_3 + ${scala.version} - - org.scala-lang - scala-library - ${scala-library.version} + org.scala-lang + scala3-compiler_3 + ${scala.version} @@ -203,10 +173,10 @@ Here, we can see that it was compiled with `2.13.5` in it's dependencies. So tha ${scala.version} - -deprecated - -explain + -Wunused:all -feature - -Ysafe-init + -deprecation + -Ysemanticdb @@ -253,28 +223,17 @@ class MyTest: ### Scala and Jackson serialization for JSON with Scala Enum support -If using Jackson for serialization, you probably want JSON support for case class and Enum. -There are two libraries you need to add to your project to enable this: - -1. The standard Jackson Scala module -2. An addon module from one of the Jackson Scala maintainers for Scala 3 enums that hasn't made its way into the official module yet +If using Jackson for serialization, you probably want JSON support for case class and Enum. Scala Jackson module already supports Scala 3 Enums built-in. To set this up: -- Add the following to your dependencies +- Add the following to your dependencies (in addition to existing `quarkus-jackson` and `quarkus-rest-jackson` extensions). ```xml com.fasterxml.jackson.module jackson-module-scala_3 - 2.16.1 - - - - com.github.pjfanning - jackson-module-scala3-enum_3 - 2.16.0 ``` @@ -438,6 +397,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d Gavin Ray
Gavin Ray

💻 🚧 Guillaume Smet
Guillaume Smet

💻 + Carlos Eduardo de Paula
Carlos Eduardo de Paula

💻 diff --git a/deployment/pom.xml b/deployment/pom.xml index 34e2699..f0d944e 100644 --- a/deployment/pom.xml +++ b/deployment/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 io.quarkiverse.scala @@ -36,7 +37,7 @@ org.scala-lang scala3-interfaces - 3.3.1 + 3.3.3
@@ -55,4 +56,4 @@ - \ No newline at end of file + diff --git a/deployment/src/main/java/io/quarkiverse/scala/scala3/deployment/Scala3Processor.java b/deployment/src/main/java/io/quarkiverse/scala/scala3/deployment/Scala3Processor.java index 01b6af8..462843c 100644 --- a/deployment/src/main/java/io/quarkiverse/scala/scala3/deployment/Scala3Processor.java +++ b/deployment/src/main/java/io/quarkiverse/scala/scala3/deployment/Scala3Processor.java @@ -9,7 +9,6 @@ class Scala3Processor { private static final String FEATURE = "scala3"; private static final String SCALA_JACKSON_MODULE = "com.fasterxml.jackson.module.scala.DefaultScalaModule"; - private static final String SCALA_JACKSON_ENUM_MODULE = "com.github.pjfanning.enum.EnumModule"; @BuildStep FeatureBuildItem feature() { @@ -17,8 +16,7 @@ FeatureBuildItem feature() { } /* - * Register the Scala Jackson module and Scala Enum module if that has been - * added to the classpath + * Register the Scala Jackson module if that has been added to the classpath * Producing the BuildItem is entirely safe since if quarkus-jackson is not on * the classpath the BuildItem will just be ignored */ @@ -27,8 +25,6 @@ void registerScalaJacksonModule(BuildProducer c try { Class.forName(SCALA_JACKSON_MODULE, false, Thread.currentThread().getContextClassLoader()); classPathJacksonModules.produce(new ClassPathJacksonModuleBuildItem(SCALA_JACKSON_MODULE)); - Class.forName(SCALA_JACKSON_ENUM_MODULE, false, Thread.currentThread().getContextClassLoader()); - classPathJacksonModules.produce(new ClassPathJacksonModuleBuildItem(SCALA_JACKSON_ENUM_MODULE)); } catch (Exception ignored) { } } diff --git a/pom.xml b/pom.xml index b80da21..16c70e3 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 io.quarkiverse @@ -24,7 +25,7 @@ UTF-8 UTF-8 - 3.6.4 + 3.10.0