Skip to content

Fix EnableLombokAnnotationProcessor to skip POMs where Lombok is already in effective POM#988

Closed
mcebanupgrade wants to merge 1 commit intoopenrewrite:mainfrom
mcebanupgrade:fix/enable-lombok-annotation-processor-effective-pom
Closed

Fix EnableLombokAnnotationProcessor to skip POMs where Lombok is already in effective POM#988
mcebanupgrade wants to merge 1 commit intoopenrewrite:mainfrom
mcebanupgrade:fix/enable-lombok-annotation-processor-effective-pom

Conversation

@mcebanupgrade
Copy link

@mcebanupgrade mcebanupgrade commented Feb 17, 2026

Summary

  • EnableLombokAnnotationProcessor was using org.openrewrite.maven.AddAnnotationProcessor, which only checks the current POM's own XML for an existing annotation processor configuration
  • This caused duplicate <path> entries when the Lombok annotation processor was already configured in an ancestor POM outside the reactor (present in the effective POM but not in any in-reactor POM's own XML)
  • Replaced with a new AddAnnotationProcessorToEffectivePom recipe (local to this module) that checks ResolvedPom.getPlugins()/getPluginManagement() (merged effective POM) vs Pom.getPlugins()/getPluginManagement() (current POM's own XML) to detect inherited configuration and skip those POMs

Note: The same fix has been proposed upstream in openrewrite/rewrite#6759 as an enhancement to AddAnnotationProcessor directly. Once that is merged and released, AddAnnotationProcessorToEffectivePom can be removed here and the YAML can revert to using org.openrewrite.maven.AddAnnotationProcessor.

Test plan

  • AddAnnotationProcessorToEffectivePomTest.addToSingleModule — adds processor when not present
  • AddAnnotationProcessorToEffectivePomTest.doesNotDuplicateWhenAlreadyInOwnXml — no change when already in own XML
  • AddAnnotationProcessorToEffectivePomTest.addToParentPluginManagementInMultiModule — adds to parent's pluginManagement in multi-module project
  • AddAnnotationProcessorToEffectivePomTest.doesNotDuplicateWhenAlreadyInEffectivePomViaAncestor — key fix: 3-level hierarchy where grandparent has Lombok in pluginManagement, intermediate parent inherits it via effective POM but has no own XML config — intermediate parent is NOT modified
  • UpgradeToJava25Test.doesNotDuplicateLombokAnnotationProcessorWhenAlreadyInParentPluginManagement — end-to-end: no duplicate <path> entry added when parent already has Lombok in pluginManagement

🤖 Generated with Claude Code

…ady in effective POM

The previous implementation used `AddAnnotationProcessor` which only checked the
current POM's own XML for an existing annotation processor configuration. This caused
duplicate entries when the Lombok annotation processor was already configured in an
ancestor POM outside the reactor (present in the effective POM but not in any in-reactor
POM's own XML).

The new `AddAnnotationProcessorToEffectivePom` recipe replicates the reactor-aware logic
of `AddAnnotationProcessor` and adds an effective POM check: if the annotation processor
is found in `ResolvedPom.getPlugins()/getPluginManagement()` (merged from all ancestors)
but NOT in `Pom.getPlugins()/getPluginManagement()` (current POM's own XML), the POM is
marked as already-configured and skipped in the visitor phase.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mcebanupgrade
Copy link
Author

Closing in favor of openrewrite/rewrite#6759

@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant

Comments