|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: 'Migration to Quarkus 3.0 is a breeze' |
| 4 | +date: 2023-05-25 |
| 5 | +tags: migration |
| 6 | +synopsis: 'Quarkus 3 is out and we encourage our users to upgrade their applications to experience the best Quarkus ever!' |
| 7 | +author: mkouba |
| 8 | +--- |
| 9 | + |
| 10 | +Quarkus 3 is out and we encourage our users to upgrade their applications to experience the best Quarkus ever! |
| 11 | +The team worked hard to deliver a lot of new features and performance improvements. |
| 12 | +But of course, there are also some breaking changes. |
| 13 | +The https://github.com/quarkusio/quarkus/wiki/Migration-Guide-3.0[migration guide] describes all the important changes in the core extensions. |
| 14 | + |
| 15 | +Nevertheless, there is also some tedious work that needs to be done. |
| 16 | +Quarkus 3 has updated to the latest Jakarta EE 10 APIs, which include the infamous change of the `javax.\*` to the `jakarta.*` packages. |
| 17 | +If your application makes use of any Jakarta API, and there's a good chance it does (think about JAX-RS, CDI, JPA, etc.), you'll need to modify your code. |
| 18 | +Furthermore, if there's an explicit Jakarta API dependency in the project, you'll need to update this dependency as well. |
| 19 | + |
| 20 | +Of course, you can migrate the application manually. |
| 21 | +But since Quarkus embraces the developer joy there is the Quarkus Update Tool to the rescue! |
| 22 | + |
| 23 | +== Quarkus Update Tool - TL;DR |
| 24 | + |
| 25 | +. Install the https://quarkus.io/guides/cli-tooling[Quarkus CLI] or make sure a 3+ version is installed |
| 26 | +. Run `quarkus update --stream=3.0` |
| 27 | +. Check the changes made by the tool |
| 28 | +. Profit! |
| 29 | + |
| 30 | +== Quarkus Update Tool - The Full Story |
| 31 | + |
| 32 | +The goal of the update tool is to help developers to migrate an application to Quarkus 3 smoothly. |
| 33 | +The update process can be triggered from the Quarkus CLI, and directly via Maven or Gradle commands. |
| 34 | +The tool itself is basically a set of https://docs.openrewrite.org/[OpenRewrite transformation rules]. |
| 35 | +Most of the rules are defined in the https://github.com/quarkusio/quarkus-updates[Quarkus Update Recipes] project. |
| 36 | + |
| 37 | +What exacty does the update tool do? |
| 38 | + |
| 39 | +* Updates the Quarkus version |
| 40 | +* Transforms the source code to use the `jakarta.*` packages |
| 41 | +* Upgrades the Quarkiverse extensions to the versions compatible with Quarkus 3.0 |
| 42 | +* Updates the Java EE API dependencies to the Jakarta EE API versions |
| 43 | +* Adjusts some common dependencies (such as Jackson and Hibernate) |
| 44 | +* Transforms the configuration files for some configuration properties (for example `quarkus.kubernetes.host` to `quarkus.kubernetes.ingress.host`) |
| 45 | +* Renames some common service providers (for example `/META-INF/services/javax.ws.rs.ext.Providers` to `/META-INF/services/jakarta.ws.rs.ext.Providers`) |
| 46 | + |
| 47 | +TIP: Maven multi-module projects with standard layout are also supported if the parent project imports a Quarkus Platform BOM. |
| 48 | + |
| 49 | +Let's get down to business. |
| 50 | +To run the update: |
| 51 | + |
| 52 | +[source,role="primary asciidoc-tabs-target-sync-cli"] |
| 53 | +.CLI |
| 54 | +---- |
| 55 | +quarkus update --stream=3.0 |
| 56 | +---- |
| 57 | + |
| 58 | +[source,role="secondary asciidoc-tabs-target-sync-maven"] |
| 59 | +.Maven |
| 60 | +---- |
| 61 | +./mvnw io.quarkus.platform:quarkus-maven-plugin:3.0.3.Final:update -N -Dstream=3.0 |
| 62 | +---- |
| 63 | + |
| 64 | +[source,role="secondary asciidoc-tabs-target-sync-gradle"] |
| 65 | +.Gradle |
| 66 | +---- |
| 67 | +./gradlew -PquarkusPluginVersion=3.0.3.Final quarkusUpdate --stream=3.0 |
| 68 | +---- |
| 69 | + |
| 70 | +IMPORTANT: If using https://quarkus.io/guides/cli-tooling[Quarkus CLI] then always make sure the latest version is used. The `quarkus version` command should output version 3+. |
| 71 | + |
| 72 | +Keep in mind that there is no dry-run mode. |
| 73 | +In other words, once you trigger the update, the changes will be immediately written to the file system. |
| 74 | +However, you can leverage the source code management tool to see the transformations applied. |
| 75 | +For example, if using Git then run the update tool and execute the `git diff` command afterwards to see the changes. |
| 76 | +And if something went wrong then just use `git checkout .` to revert the changes. |
| 77 | + |
| 78 | +TIP: If your application depends on Hibernate ORM, the dedicated https://github.com/quarkusio/quarkus/wiki/Migration-Guide-3.0:-Hibernate-ORM-5-to-6-migration[Hibernate ORM 5 to 6] migration guide will come in handy. |
| 79 | + |
| 80 | +That's it. |
| 81 | +Your application should be ready now. |
| 82 | +If there's something wrong please, ping us on Zulip or file a https://github.com/quarkusio/quarkus/issues[new issue]. |
| 83 | + |
| 84 | +== Summary |
| 85 | + |
| 86 | +In this article, we discussed the possibilities of the Quarkus Update Tool that will make your migration to Quarkus 3.0 a breeze. |
| 87 | +Don't hesitate and go for it! |
| 88 | + |
| 89 | +NOTE: The Quarkus Update Tool is not a one-time thing. The plan is to use this tool to provide easy updates for the future versions of Quarkus as well. |
| 90 | + |
| 91 | +== More resources |
| 92 | + |
| 93 | +- https://github.com/quarkusio/quarkus/wiki/Migration-Guide-3.0[Migration Guide 3.0] |
| 94 | +- https://github.com/quarkusio/quarkus/wiki/Migration-Guide-3.0:-Hibernate-ORM-5-to-6-migration[Migration Guide 3.0 - Hibernate ORM 5 to 6] |
| 95 | +- https://github.com/quarkusio/quarkus-updates[Quarkus Update Recipes] |
| 96 | +- https://quarkus.io/guides/cli-tooling[Quarkus CLI] |
| 97 | + |
0 commit comments