Only add lombok annotation processor to modules that use lombok#1031
Merged
Jenson3210 merged 5 commits intomainfrom Mar 30, 2026
Merged
Only add lombok annotation processor to modules that use lombok#1031Jenson3210 merged 5 commits intomainfrom
Jenson3210 merged 5 commits intomainfrom
Conversation
…projects RepositoryHasDependency marks all files if any module has lombok, causing AddAnnotationProcessor to run on modules without lombok.
…ionProcessor RepositoryHasDependency checks the whole repo and marks ALL files when any module has lombok, causing AddAnnotationProcessor to run on modules without lombok. Switch to DependencyInsight which checks per-module, matching the pattern used by AddLombokMapstructBinding. Fixes moderneinc/customer-requests#2110
DependencyInsight doesn't resolve dependencies in nested mavenProject test structures (test infrastructure limitation). The sibling mavenProject test already proves the per-module behavior correctly.
…recision Switch to ModuleHasDependency which is designed as a per-module precondition using ScanningRecipe to collect JavaProject markers. This is the proper counterpart to RepositoryHasDependency for module-scoped checks, and removes the need for the Singleton wrapper.
timtebeek
reviewed
Mar 30, 2026
| </dependencies> | ||
| </project> | ||
| """, | ||
| spec -> spec.after(actual -> actual) |
Member
There was a problem hiding this comment.
Should we validate the annotation processor was added here?
timtebeek
approved these changes
Mar 30, 2026
Member
timtebeek
left a comment
There was a problem hiding this comment.
Approved already, but perhaps good to have an assertion that the processor is actually added.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EnableLombokAnnotationProcessorprecondition fromRepositoryHasDependencytoDependencyInsightProblem
EnableLombokAnnotationProcessorusedRepositoryHasDependencyas its precondition, which checks the entire repository. If any module has lombok as a dependency, the annotation processor gets added to ALL modules — including those that don't use lombok. This causes unexpectedmaven-compiler-pluginconfiguration changes in projects without lombok.Solution
Switch the precondition from
RepositoryHasDependency(repo-wide) toDependencyInsight(per-module). This matches the pattern already used byAddLombokMapstructBindingand ensures the annotation processor is only added to modules that actually declare lombok as a dependency.Test plan
Existing
UpgradeToJava25Test.addsLombokAnnotationProcessorpasses (positive case)Existing
UpgradeToJava17TestpassesNew test:
doesNotAddLombokToModuleWithoutLombok— multi-module project where one module has lombok and another doesn't; only the lombok module gets the annotation processorNew test:
doesNotAddLombokWhenNotPresent— single module without lombok gets no changesNew test:
doesNotAddLombokWhenNotPresentViaUpgradeToJava25— same via composite recipeFixes moderneinc/customer-requests#2110