Skip to content

Commit 03a5797

Browse files
committed
Bump Quarkus so module is built-in. Update readme.
1 parent a1be83e commit 03a5797

File tree

4 files changed

+53
-95
lines changed

4 files changed

+53
-95
lines changed

README.md

Lines changed: 45 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
- [Functional HTTP routes (Vert.x handlers)](#functional-http-routes-vertx-handlers)
1919
- [Contributors ✨](#contributors-)
2020

21-
## Introduction
21+
## Introduction
2222

2323
This extension provides support for Scala 3 in Quarkus.
2424

@@ -51,43 +51,23 @@ repositories {
5151
}
5252
5353
VERSIONS = [
54-
QUARKUS_SCALA3: "0.0.1",
55-
SCALA3 : "3.1.0",
56-
SCALA_LIBRARY : "2.13.6",
57-
// Scala Jackson at time of writing doesn't support Scala 3 Enum's natively. It requires another library.
58-
// That library doesn't support same version of Jackson that Quarkus BOM uses (2.12.5), so this is the best compromise
59-
// https://search.maven.org/artifact/com.github.pjfanning/jackson-module-scala3-enum_3/2.12.3/jar
60-
JACKSON : "2.12.3"
54+
QUARKUS: "3.10.0",
55+
QUARKUS_SCALA3: "1.0.0",
56+
SCALA3 : "3.3.3",
6157
]
6258
6359
dependencies {
60+
implementation enforcedPlatform("io.quarkus.platform:quarkus-bom:${VERSIONS.QUARKUS}")
6461
implementation "io.quarkiverse.scala:quarkus-scala3:${VERSIONS.QUARKUS_SCALA3}"
65-
implementation("org.scala-lang:scala3-compiler_3") {
66-
version {
67-
strictly VERSIONS.SCALA3
68-
}
69-
}
70-
implementation("org.scala-lang:scala3-library_3") {
71-
version {
72-
strictly VERSIONS.SCALA3
73-
}
74-
}
75-
implementation("org.scala-lang:scala-library") {
76-
version {
77-
strictly VERSIONS.SCALA_LIBRARY
78-
}
79-
}
62+
implementation "org.scala-lang:scala3-library_3:${VERSIONS.SCALA3}"
63+
implementation "org.scala-lang:scala3-compiler_3:${VERSIONS.SCALA3}"
8064
81-
// Quarkus comes with Scala 2 distributed in it's Bill-of-Materials unfortunately
82-
// It's Scala 2.12.13, which is not ABI compatible -- With Scala 3, we need to exclude this entirely
83-
implementation(enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")) {
84-
exclude group: 'org.scala-lang', module: 'scala-library'
85-
}
8665
implementation "io.quarkus:quarkus-arc"
8766
implementation "io.quarkus:quarkus-resteasy-reactive"
8867
89-
implementation "com.fasterxml.jackson.module:jackson-module-scala_3:${VERSIONS.JACKSON}"
90-
implementation "com.github.pjfanning:jackson-module-scala3-enum_3:${VERSIONS.JACKSON}"
68+
implementation "io.quarkus:quarkus-jackson"
69+
implementation "io.quarkus:quarkus-rest-jackson"
70+
implementation "com.fasterxml.jackson.module:jackson-module-scala_3"
9171
9272
testImplementation "io.quarkus:quarkus-junit5"
9373
testImplementation "io.rest-assured:rest-assured"
@@ -97,31 +77,24 @@ group = "org.acme"
9777
version = "1.0.0-SNAPSHOT"
9878
9979
java {
100-
// Set to 17 for performance reasons, feel free to change to 11 or 8
101-
sourceCompatibility = JavaVersion.VERSION_17
102-
targetCompatibility = JavaVersion.VERSION_17
80+
sourceCompatibility = JavaVersion.VERSION_21
81+
targetCompatibility = JavaVersion.VERSION_21
10382
}
10483
10584
tasks.withType(ScalaCompile) {
10685
scalaCompileOptions.additionalParameters = [
107-
"-feature", // Emit warnings and locations for features that should be imported explicitly
108-
"-explain", // Explain (type) errors in more detail
109-
"-Ysafe-init", // Ensure safe initialization of objects (prevent null object init)
110-
"-Yrequire-targetName", // Warn if an operator is defined without a @targetName annotation
111-
// "-Yexplicit-nulls", // Make reference types non-nullable. Nullable types can be expressed with unions: e.g. String|Null.
112-
113-
// I am unsure if this is required for proper tooling to work. Metals/IntelliJ may already cover this.
114-
"-Xsemanticdb", // Store information in SemanticDB
86+
"-feature",
87+
"-Wunused:all",
11588
]
11689
}
11790
11891
compileJava {
119-
options.encoding = 'UTF-8'
120-
options.compilerArgs << '-parameters'
92+
options.encoding = "UTF-8"
93+
options.compilerArgs << "-parameters"
12194
}
12295
12396
compileTestJava {
124-
options.encoding = 'UTF-8'
97+
options.encoding = "UTF-8"
12598
}
12699
```
127100

@@ -131,43 +104,40 @@ If you want to use this extension, you need to add the `io.quarkiverse.scala:qua
131104
In your `pom.xml` file, add:
132105

133106
```xml
134-
<dependency>
135-
<groupId>io.quarkiverse.scala</groupId>
136-
<artifactId>quarkus-scala3</artifactId>
137-
<version>0.0.1<version>
138-
</dependency>
107+
<dependencies>
108+
...
109+
<dependency>
110+
<groupId>io.quarkiverse.scala</groupId>
111+
<artifactId>quarkus-scala3</artifactId>
112+
<version>0.0.1<version>
113+
</dependency>
114+
...
139115
```
140116

141-
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.
142-
143-
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.
144-
145-
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.
146-
147-
So for `scala3-compiler_3` = `3.0.0`, then `scala3-library_3` = `3.0.0`, and we check the `scala-library` version it uses:
148-
- https://mvnrepository.com/artifact/org.scala-lang/scala3-library_3/3.0.0
149-
150-
Here, we can see that it was compiled with `2.13.5` in it's dependencies. So that's what we set in ours:
117+
Then, you will need to add the Scala 3 compiler and library and the Scala Maven plugin:
151118

152119
```xml
153120
<properties>
154-
<scala-maven-plugin.version>4.5.3</scala-maven-plugin.version>
155-
<scala.version>3.1.0</scala.version>
156-
<scala-library.version>2.13.6</scala-library.version>
121+
<scala-maven-plugin.version>4.9.1</scala-maven-plugin.version>
122+
<scala.version>3.3.3</scala.version>
157123
</properties>
158124

159125
<dependencies>
160126
<!-- Scala Dependencies -->
161127
<dependency>
162-
<groupId>org.scala-lang</groupId>
163-
<artifactId>scala3-compiler_3</artifactId>
164-
<version>${scala.version}</version>
128+
<groupId>io.quarkiverse.scala</groupId>
129+
<artifactId>quarkus-scala3</artifactId>
130+
<version>1.0.0</version>
131+
</dependency>
132+
<dependency>
133+
<groupId>org.scala-lang</groupId>
134+
<artifactId>scala3-library_3</artifactId>
135+
<version>${scala.version}</version>
165136
</dependency>
166137
<dependency>
167-
<!-- Version manually aligned to scala3-library_3:3.0.0 dependency -->
168-
<groupId>org.scala-lang</groupId>
169-
<artifactId>scala-library</artifactId>
170-
<version>${scala-library.version}</version>
138+
<groupId>org.scala-lang</groupId>
139+
<artifactId>scala3-compiler_3</artifactId>
140+
<version>${scala.version}</version>
171141
</dependency>
172142
</dependencies>
173143

@@ -203,10 +173,10 @@ Here, we can see that it was compiled with `2.13.5` in it's dependencies. So tha
203173
<scalaVersion>${scala.version}</scalaVersion>
204174
<!-- Some solid defaults, change if you like -->
205175
<args>
206-
<arg>-deprecated</arg>
207-
<arg>-explain</arg>
176+
<arg>-Wunused:all</arg>
208177
<arg>-feature</arg>
209-
<arg>-Ysafe-init</arg>
178+
<arg>-deprecation</arg>
179+
<arg>-Ysemanticdb</arg>
210180
</args>
211181
</configuration>
212182
</plugin>
@@ -253,28 +223,17 @@ class MyTest:
253223

254224
### Scala and Jackson serialization for JSON with Scala Enum support
255225

256-
If using Jackson for serialization, you probably want JSON support for case class and Enum.
257-
There are two libraries you need to add to your project to enable this:
258-
259-
1. The standard Jackson Scala module
260-
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
226+
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.
261227

262228
To set this up:
263229

264-
- Add the following to your dependencies
230+
- Add the following to your dependencies (in addition to existing `quarkus-jackson` and `quarkus-rest-jackson` extensions).
265231

266232
```xml
267233
<!-- JSON Serialization Dependencies -->
268234
<dependency>
269235
<groupId>com.fasterxml.jackson.module</groupId>
270236
<artifactId>jackson-module-scala_3</artifactId>
271-
<version>2.16.1</version>
272-
</dependency>
273-
274-
<dependency>
275-
<groupId>com.github.pjfanning</groupId>
276-
<artifactId>jackson-module-scala3-enum_3</artifactId>
277-
<version>2.16.0</version>
278237
</dependency>
279238
```
280239

@@ -438,6 +397,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
438397
<tr>
439398
<td align="center" valign="top" width="14.28%"><a href="https://github.com/GavinRay97"><img src="https://avatars.githubusercontent.com/u/26604994?v=4?s=100" width="100px;" alt="Gavin Ray"/><br /><sub><b>Gavin Ray</b></sub></a><br /><a href="https://github.com/quarkiverse/quarkus-scala3/commits?author=GavinRay97" title="Code">💻</a> <a href="#maintenance-GavinRay97" title="Maintenance">🚧</a></td>
440399
<td align="center" valign="top" width="14.28%"><a href="https://lesincroyableslivres.fr/"><img src="https://avatars.githubusercontent.com/u/1279749?v=4?s=100" width="100px;" alt="Guillaume Smet"/><br /><sub><b>Guillaume Smet</b></sub></a><br /><a href="https://github.com/quarkiverse/quarkus-scala3/commits?author=gsmet" title="Code">💻</a></td>
400+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/carlosedp"><img src="https://avatars.githubusercontent.com/u/20382?s=400&u=ea5348eac48fb226dc5bc4954f5408764c5914a6&v=4" width="100px;" alt="Carlos Eduardo de Paula"/><br /><sub><b>Carlos Eduardo de Paula</b></sub></a><br /><a href="https://github.com/quarkiverse/quarkus-scala3/commits?author=carlosedp" title="Code">💻</a></td>
441401
</tr>
442402
</tbody>
443403
</table>

deployment/pom.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45
<parent>
56
<groupId>io.quarkiverse.scala</groupId>
@@ -36,7 +37,7 @@
3637
<dependency>
3738
<groupId>org.scala-lang</groupId>
3839
<artifactId>scala3-interfaces</artifactId>
39-
<version>3.3.1</version>
40+
<version>3.3.3</version>
4041
</dependency>
4142
</dependencies>
4243
<build>
@@ -55,4 +56,4 @@
5556
</plugin>
5657
</plugins>
5758
</build>
58-
</project>
59+
</project>

deployment/src/main/java/io/quarkiverse/scala/scala3/deployment/Scala3Processor.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ class Scala3Processor {
99

1010
private static final String FEATURE = "scala3";
1111
private static final String SCALA_JACKSON_MODULE = "com.fasterxml.jackson.module.scala.DefaultScalaModule";
12-
private static final String SCALA_JACKSON_ENUM_MODULE = "com.github.pjfanning.enum.EnumModule";
1312

1413
@BuildStep
1514
FeatureBuildItem feature() {
1615
return new FeatureBuildItem(FEATURE);
1716
}
1817

1918
/*
20-
* Register the Scala Jackson module and Scala Enum module if that has been
21-
* added to the classpath
19+
* Register the Scala Jackson module if that has been added to the classpath
2220
* Producing the BuildItem is entirely safe since if quarkus-jackson is not on
2321
* the classpath the BuildItem will just be ignored
2422
*/
@@ -27,8 +25,6 @@ void registerScalaJacksonModule(BuildProducer<ClassPathJacksonModuleBuildItem> c
2725
try {
2826
Class.forName(SCALA_JACKSON_MODULE, false, Thread.currentThread().getContextClassLoader());
2927
classPathJacksonModules.produce(new ClassPathJacksonModuleBuildItem(SCALA_JACKSON_MODULE));
30-
Class.forName(SCALA_JACKSON_ENUM_MODULE, false, Thread.currentThread().getContextClassLoader());
31-
classPathJacksonModules.produce(new ClassPathJacksonModuleBuildItem(SCALA_JACKSON_ENUM_MODULE));
3228
} catch (Exception ignored) {
3329
}
3430
}

pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45
<parent>
56
<groupId>io.quarkiverse</groupId>
@@ -24,7 +25,7 @@
2425
<properties>
2526
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2627
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
27-
<quarkus.version>3.6.4</quarkus.version>
28+
<quarkus.version>3.10.0</quarkus.version>
2829
</properties>
2930
<dependencyManagement>
3031
<dependencies>

0 commit comments

Comments
 (0)