Conditionally enable OpenRewrite per module via marker files#23060
Draft
gnodet wants to merge 1 commit intoapache:mainfrom
Draft
Conditionally enable OpenRewrite per module via marker files#23060gnodet wants to merge 1 commit intoapache:mainfrom
gnodet wants to merge 1 commit intoapache:mainfrom
Conversation
Contributor
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
Contributor
|
🧪 CI tested the following changed modules:
|
ed93c75 to
46d399c
Compare
This was referenced May 7, 2026
Contributor
Author
|
Claude Code on behalf of Guillaume Nodet Benchmark resultsTested with two companion PRs to measure the impact:
~8 minutes saved (~36% faster) on builds that don't introduce FQCNs, which is the common case (dependency bumps, doc changes, clean code). When FQCNs are detected, OpenRewrite runs as before — no regression in correctness. |
Instead of always running OpenRewrite on all modules (which adds ~8 min to every build), use Maven file-activated profiles to run it only on modules with changed Java files. Before the build, regen.sh creates .rewrite-enabled marker files in modules that have modified Java files. The rewrite profile in parent/pom.xml activates when this file exists, so OpenRewrite runs only where needed. This approach is recipe-agnostic — adding new OpenRewrite recipes to the profile requires no changes to the detection logic. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Follow-up to #23041 which disabled OpenRewrite entirely because it quadrupled CI build times.
This re-enables OpenRewrite using Maven's file-activated profiles, scoped to only the modules that have changed Java files. Most builds skip OpenRewrite entirely, and when it does run, it only processes the affected modules.
How it works
regen.shdetects which modules have modified.javafiles (viagit diff HEAD~1 HEAD --name-only).rewrite-enabledmarker file in each affected modulerewriteprofile inparent/pom.xmluses<activation><file><exists>.rewrite-enabled</exists></file></activation>— Maven evaluates this per-module, so OpenRewrite only runs where the marker exists-Prewriteflag needed — everything is automaticThis approach is recipe-agnostic: adding new OpenRewrite recipes to the profile requires no changes to the detection logic.
For shallow clones in CI,
--deepen=1fetches just the parent commit. For PRs,HEAD~1is the base branch tip (first parent of the merge commit). For main builds, it's the previous squash-merged commit.Benchmark results (from earlier test PRs)
~8 minutes saved (~36% faster) on builds that don't introduce FQCNs.
With the per-module approach, even builds that trigger OpenRewrite will be faster since it only processes changed modules instead of all ~500.
Test plan
components/camel-telemetry)--deepen=1).rewrite-enabledadded to.gitignore