Skip to content

Add lombok.config recipes - #1236

Open
sullis wants to merge 1 commit into
openrewrite:mainfrom
sullis:consolidate-lombok-config
Open

sullis wants to merge 1 commit into
openrewrite:mainfrom
sullis:consolidate-lombok-config

Conversation

@sullis

@sullis sullis commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Adds two lombok.config recipes, built on a shared LombokConfig helper that parses a config file following the line grammar of Lombok's own ConfigurationParser. Both act on the lombok.config at the root of the repository, and read any *.config file, since an import names a file by path rather than by name.

Neither recipe is part of LombokBestPractices; both are registered in recipes.csv and are run on their own.

ConsolidateLombokConfig

Merges the directives of every nested lombok.config into the root lombok.config and deletes the nested files.

  • Directives are appended, so whatever the root already contains is left exactly as written. Directives it already declares, itself or through an import, are dropped rather than repeated; whitespace and key case are normalized for comparison only.
  • Nested files are merged shallowest first, the order Lombok reads them in.
  • A nested file stays in place when hoisting it would change what Lombok does: it declares config.stopBubbling or sits under a directory that does, it has an import, clear or -=, a lombok.config between it and the root speaks about one of the same directives, another lombok.config imports it, no Java source sits at or below it, or it holds nothing but comments and unparseable lines.
  • No changes are made at all when there is no root lombok.config, when two files assign conflicting values to the same key, when the root clears or -=s a key a nested file speaks about, or when the root's imports cannot be resolved.

Note that hoisting widens a directive's scope from one directory to the whole project, which the recipe description calls out.

AddStopBubblingToLombokConfig

Appends config.stopBubbling = true to the root lombok.config unless it already declares that key. Without it, Lombok keeps walking up past the project and a lombok.config in a parent directory of the checkout takes part in the build.

  • Nothing is added when the key is already declared, whatever value it is assigned and whether the root declares or imports it, or when the root's imports cannot be resolved.
  • Only the root file is changed.

Tests

79 tests covering merging and merge order, deduplication, conflict detection, each non-hoistable case, stopBubbling ancestors, import resolution and cycles, comment handling, case-insensitive keys, Java-source layout, and CRLF and missing-trailing-newline root files.

🤖 Generated with Claude Code

@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Sep 9, 2026
@sullis
sullis force-pushed the consolidate-lombok-config branch 4 times, most recently from d5a4e5d to 6850300 Compare September 10, 2026 02:11
@sullis sullis changed the title Add ConsolidateLombokConfig Add lombok.config recipes Sep 10, 2026
@sullis
sullis force-pushed the consolidate-lombok-config branch 3 times, most recently from 028c6d2 to dfc4575 Compare September 10, 2026 02:48
@sullis
sullis marked this pull request as ready for review September 10, 2026 03:13
@sullis

sullis commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Ready for review @greg-at-moderne @timtebeek

@greg-at-moderne greg-at-moderne left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change itself looks line to me. I appreciate the defensive approach.

The only thing I'd kindly request is getting rid of the verbosity and excessive comments/texts.

@sullis
sullis force-pushed the consolidate-lombok-config branch 2 times, most recently from 6a07713 to dfc4575 Compare September 17, 2026 18:00
@greg-at-moderne
greg-at-moderne self-requested a review September 17, 2026 18:04
@sullis
sullis force-pushed the consolidate-lombok-config branch from f424e96 to 0644d5e Compare September 17, 2026 18:04
@sullis

sullis commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

The change itself looks line to me. I appreciate the defensive approach.

The only thing I'd kindly request is getting rid of the verbosity and excessive comments/texts.

I pushed an update.

@sullis
sullis force-pushed the consolidate-lombok-config branch from 67f9cfb to 8f14a52 Compare September 17, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants