Skip to content

Conditionally enable OpenRewrite per module via marker files#23060

Draft
gnodet wants to merge 1 commit intoapache:mainfrom
gnodet:elderly-mackerel
Draft

Conditionally enable OpenRewrite per module via marker files#23060
gnodet wants to merge 1 commit intoapache:mainfrom
gnodet:elderly-mackerel

Conversation

@gnodet
Copy link
Copy Markdown
Contributor

@gnodet gnodet commented May 7, 2026

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

  1. regen.sh detects which modules have modified .java files (via git diff HEAD~1 HEAD --name-only)
  2. Creates a .rewrite-enabled marker file in each affected module
  3. The rewrite profile in parent/pom.xml uses <activation><file><exists>.rewrite-enabled</exists></file></activation> — Maven evaluates this per-module, so OpenRewrite only runs where the marker exists
  4. No -Prewrite flag needed — everything is automatic

This approach is recipe-agnostic: adding new OpenRewrite recipes to the profile requires no changes to the detection logic.

For shallow clones in CI, --deepen=1 fetches just the parent commit. For PRs, HEAD~1 is 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)

PR OpenRewrite Build time (JDK 21)
#23068 (no FQCNs) skipped ~22 min
#23069 (with FQCNs) triggered ~30 min

~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

  • Tested module detection locally against real commits
  • Correctly identifies affected modules (e.g. components/camel-telemetry)
  • No modules detected for non-Java changes (dep bumps)
  • Handles shallow clones (--deepen=1)
  • .rewrite-enabled added to .gitignore
  • Verify CI passes with this change

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@gnodet gnodet marked this pull request as draft May 7, 2026 14:14
@gnodet gnodet force-pushed the elderly-mackerel branch from 624ac55 to 6d55874 Compare May 7, 2026 14:15
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

🧪 CI tested the following changed modules:

  • etc

⚙️ View full build and test results

@gnodet
Copy link
Copy Markdown
Contributor Author

gnodet commented May 7, 2026

Claude Code on behalf of Guillaume Nodet

Benchmark results

Tested with two companion PRs to measure the impact:

PR OpenRewrite Build time (JDK 21)
#23068 (no FQCNs) skipped ~22 min
#23069 (with FQCNs) triggered ~30 min

~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.

@gnodet gnodet marked this pull request as ready for review May 7, 2026 21:02
@gnodet gnodet requested review from apupier and oscerd May 7, 2026 21:02
@gnodet gnodet marked this pull request as draft May 11, 2026 11:08
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>
@gnodet gnodet force-pushed the elderly-mackerel branch from 46d399c to 8629333 Compare May 11, 2026 11:08
@gnodet gnodet changed the title Conditionally enable OpenRewrite FQCN shortening in CI Conditionally enable OpenRewrite per module via marker files May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant