Upgrading to Axon Framework 4.7 - Automated
Automation through OpenRewrite
In a previous blog, we explained our discontent and reasoning behind the introduction of breaking changes in Axon Framework 4.7.
Our desire to support Spring Boot 3 and Spring Framework 6 required us to deal with the hard shift from Javax to Jakarta by introducing dedicated legacy packages for the former (Javax), making the latter (Jakarta) the default. We are confident that, although it requires some work when upgrading, this shift improves the overall stability of the project.
As part of the effort to switch from Javax to Jakarta, the Framework team discussed whether we should provide OpenRewrite scripts. For those unaware: OpenRewrite is a library dedicated to "mass source code refactoring," thus simplifying the task of resolving breaking changes. For example, you can find OpenRewrite recipes for migrating to Java 17 and Spring Boot 3. Therefore, we deemed it an ideal candidate to ease migration to Axon Framework 4.7.
We agreed that OpenRewrite is a valuable topic to research, but we did not have sufficient resources to work on this ASAP. Instead, we've put it on our backlog to delve into once Axon Framework 5 comes into play.
Axon Migration Module
Soon after this discussion, we proved to be lucky. We received an issue and pull request from Tim te Beek to provide OpenRewrite recipes for Axon Framework 4.7! Hence, as of release 4.7.2 of Axon Framework, there's a new module present: `axon-migration`.
This module contains two recipes based on the verbal explanation in the previous blog:
-
Upgrade to Axon Framework 4.7 Jakarta - A recipe to upgrade from an Axon Framework Javax-specific project to Jakarta.
-
Upgrade to Axon Framework 4.7 Javax - A recipe to upgrade an Axon Framework Javax-specific project and remain on Javax.
As shown in the readme of the axon-migration module, all you'd have to do to migrate to 4.7 and stick with Javax is:
mvn -U org.openrewrite.maven:rewrite-maven-plugin:4.40.0:run \
-Drewrite.recipeArtifactCoordinates=org.axonframework:axon-migration:LATEST \
-DactiveRecipes=org.axonframework.migration.UpgradeAxonFramework_4_7_Javax
Although the above sample uses Maven, you can, of course, use Gradle just as well. To that end, we recommend you check out the following documentation from OpenRewrite.
Instead of sticking to Javax with Axon Framework 4.7, you can also combine a migration to Java 17, Spring Boot 3, and Axon Framework 4.7 Jakarta in one go:
mvn -U org.openrewrite.maven:rewrite-maven-plugin:4.40.0:run \
-Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-spring:4.33.0,org.axonframework:axon-migration:LATEST \
-DactiveRecipes=org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_0,org.axonframework.migration.UpgradeAxonFramework_4_7_Jakarta
Conclusion
With the introduction of OpenRewrite, we believe migrating to Axon Framework 4.7 is made more straightforward. Furthermore, we will add or update the scripts accordingly for future breaking changes, especially for Axon Framework 5.
If you try the recipes, but something's amiss, be sure to reach out! We gladly receive feedback on AxonIQ's forum. Similarly, if the predicament is OpenRewrite-specific, they'll surely help you out.