Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[#3195] feat(migration): OpenRewrite script to help with migration from Axon Framework 4.x to Axoniq Framework 5.x#4549

Open
MateuszNaKodach wants to merge 8 commits intoaxon-5.1.xAxonIQ/AxonFramework:axon-5.1.xfrom
feat/5.1-openrewriteAxonIQ/AxonFramework:feat/5.1-openrewriteCopy head branch name to clipboard
Open

[#3195] feat(migration): OpenRewrite script to help with migration from Axon Framework 4.x to Axoniq Framework 5.x#4549
MateuszNaKodach wants to merge 8 commits intoaxon-5.1.xAxonIQ/AxonFramework:axon-5.1.xfrom
feat/5.1-openrewriteAxonIQ/AxonFramework:feat/5.1-openrewriteCopy head branch name to clipboard

Conversation

@MateuszNaKodach
Copy link
Copy Markdown
Contributor

Important for reviews

Don’t focus on the OpenRewrite scripts; instead, focus on the tests to verify whether they correctly modify the target project’s code.

How to run?

In order to test it on your own repository:

  • build Axon Framework 5 locally (because the migration module is not yet published)
  • build Axoniq Framework 5 locally

Execute in the repo to be migrated:

mvn -U org.openrewrite.maven:rewrite-maven-plugin:run \
  -Drewrite.recipeArtifactCoordinates=org.axonframework:axon-migration:5.1.1-SNAPSHOT \
  -Drewrite.activeRecipes=org.axonframework.migration.UpgradeAxon4ToAxoniq5

And be happy because of:

[WARNING] Estimate time saved: 26h 16m

If you find any places that weren’t migrated as expected by OpenRewrite, ask Claude to update the migration recipes and provide the AI agent with both the expected outcome and the mistake it made.

@MateuszNaKodach MateuszNaKodach added this to the Release 5.1.1 milestone May 7, 2026
@MateuszNaKodach MateuszNaKodach self-assigned this May 7, 2026
@MateuszNaKodach MateuszNaKodach requested a review from a team as a code owner May 7, 2026 14:23
@MateuszNaKodach MateuszNaKodach added Type: Feature Use to signal an issue is completely new to the project. Priority 2: Should High priority. Ideally, these issues are part of the release they’re assigned to. labels May 7, 2026
@MateuszNaKodach MateuszNaKodach requested review from hjohn, jangalinski and laura-devriendt-lemon and removed request for a team May 7, 2026 14:23
@MateuszNaKodach MateuszNaKodach changed the title feat(migration): OpenRewrite script to help with migration from Axon Framework 4.x to Axoniq Framework 5.x [#3195] feat(migration): OpenRewrite script to help with migration from Axon Framework 4.x to Axoniq Framework 5.x May 7, 2026
…n 4.x to 5.x migration

- Add `ConfigureEventSourcedAnnotationKotlinTest` to verify Kotlin-specific behaviors in migration recipes.
- Introduce `ConvertCommandHandlerConstructorToCompanionObject` recipe to rewrite Kotlin `@CommandHandler` constructors into companion object methods meeting Axon 5.x requirements.
- Add `ConvertCommandHandlerConstructorToCompanionObjectTest` to validate the recipe.
- Add `MigrateAggregateTestFixtureSetupKotlinTest` to confirm Kotlin-compatible test fixture setup migration with proper class literal handling.
- Replace fully qualified references with simple imports for `@CommandHandler` and `EventAppender`.
- Update Kotlin migration recipes to ensure imports are correctly added for compatibility with Axon 5.x.
- Introduce Kotlin upgrade step in migration YAML to support dependency and plugin alignment with Kotlin 2.x.
- Improve handling of `CommandHandler` in companion object transformations to prevent import clashes during migration.
- Introduce `AddEventTagAnnotationKotlinTest` to validate annotation of Kotlin primary constructor parameters.
- Update `AddEventTagAnnotation` recipe to handle Kotlin-specific constructs such as `data class` primary constructors and `val/var` fields.
- Improve annotation handling for Kotlin sources to ensure `@EventTag` is correctly applied and formatted.
- Add test to validate fallback annotation placement for mismatched Kotlin field names.
- Refactor `AddEventTagAnnotation` to properly handle Kotlin `data class` field declaration order.
- Fix `isFirstFieldInClass` implementation to ensure correct field lookup in Kotlin and Java classes.
@MateuszNaKodach MateuszNaKodach force-pushed the feat/5.1-openrewrite branch from 54c81f6 to 056a3d1 Compare May 8, 2026 22:31
@MateuszNaKodach MateuszNaKodach requested review from hatzlj and smcvb May 8, 2026 22:31
Closes the Gradle gap in `axon-migration` so the BOM rename + version
pin works end-to-end on Maven *and* Gradle projects (Groovy DSL,
Kotlin DSL, plain `platform(...)`, Spring Dependency Management
`mavenBom(...)`, and the Cinema-style `extra["axonFrameworkVersion"]`
+ `${property("...")}` indirection).

- Ship `migration/init.gradle` and document the Gradle invocation
  (`gradle rewriteRun --init-script ...`) in the module README.
- Compose `gradle.ChangeManagedDependency` and
  `gradle.ChangeExtraProperty` into the BOM YAMLs so Spring DM imports
  and Groovy `ext.*` version properties get rewritten alongside the
  existing Maven and `gradle.ChangeDependency` legs.
- Add `MigrateKotlinDslBomImport`, a small Kotlin-DSL-only recipe that
  fills two upstream gaps: `SpringDependencyManagementPluginEntry`
  doesn't extract version variables from `K.StringTemplate` whose
  embedded expression is `property("...")`, and `ExtraProperty` doesn't
  match the Kotlin-subscript `extra["..."] = "..."` shape. The recipe
  rewrites the `groupId:artifactId:` prefix in `mavenBom(...)` while
  preserving the `${property(...)}` indirection, and updates the
  matching `extra["..."]` literal in the same pass.
- Cover the new Gradle paths with `Axon4ToAxon5BomGradleTest` (Groovy
  + Kotlin DSL, both free and commercial legs, including the
  Cinema-style fixture). Tests attach a synthetic `GradleProject`
  marker rather than spinning up a Gradle daemon via `withToolingApi()`,
  keeping them lightweight (no `gradle-tooling-api` test dep needed).
- Expand annotation rewrites: add `@AggregateRoot` → `@EventSourcedEntity`, and clarify the removal of `@AggregateIdentifier` in favor of `tagKey` + `@EventTag`.
- Document unconditional removal of `@CreationPolicy`, including `AggregateCreationPolicy`, and explain handling for `CREATE_IF_MISSING` and `ALWAYS`.
- Provide additional guidance on lifted `@RoutingKey` and placement of `@EntityCreator` in constructors.
…nTestFixture` cleanup

- Introduce `AddAxonTestFixtureTearDown` recipe to automatically generate an `@AfterEach tearDown()` method calling `fixture.stop()`, ensuring proper lifecycle management for `AxonTestFixture` in JUnit 5 tests.
- Skip classes with existing `@AfterEach` methods or methods named `tearDown` to avoid duplication.
- Limit changes to Java sources only; Kotlin support to be addressed separately.
- Add comprehensive tests to verify correct migration behavior and idempotence.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 9, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority 2: Should High priority. Ideally, these issues are part of the release they’re assigned to. Type: Feature Use to signal an issue is completely new to the project.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.