Conditionally enable OpenRewrite per module via marker files#23060
Conditionally enable OpenRewrite per module via marker files#23060gnodet wants to merge 1 commit into
Conversation
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
✅ POM dependency changes: targeted tests included Changed properties: exists Changed managed plugins: com.mycila:license-maven-plugin Modules affected by dependency changes (669)
All tested modules (671 modules)
|
ed93c75 to
46d399c
Compare
|
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. |
a3a8e12 to
4eda1ce
Compare
|
Claude Code on behalf of Guillaume Nodet Benchmark results (marker file approach)Tested with two companion PRs to validate the per-module marker file approach:
With the per-module approach, OpenRewrite on a single module adds only ~1.5 min (vs ~8 min when running on all modules with the old Both PRs: regen succeeded, no uncommitted changes from marker files, license plugin handled correctly. Test step failures in #23122/#23123 are unrelated (flaky camel-ftp port binding — Main PR #23060 passed all CI checks (JDK 17, 21, 25). |
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>
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