RewriteTest: framework-agnostic ExecutionContext customizer registry#7559
Merged
jkschneider merged 5 commits intomainfrom May 4, 2026
Merged
RewriteTest: framework-agnostic ExecutionContext customizer registry#7559jkschneider merged 5 commits intomainfrom
jkschneider merged 5 commits intomainfrom
Conversation
Adds `RewriteTest.defaultExecutionContextCustomizers`, a `Map<Class<?>, Consumer<ExecutionContext>>` applied to the context built by `defaultExecutionContext`. Test framework integrations (JUnit, TestNG, Spock, …) can register a customizer keyed by their own class without `rewrite-test` taking a dependency on any framework; `putIfAbsent` makes registration naturally idempotent. First consumer: a JUnit Jupiter `BeforeAllCallback` in rewrite-gradle's test sources, auto-detected via service loader, that loads `~/.m2/settings.xml` into the ExecutionContext. Recipes resolving Maven artifacts during rewrite-gradle tests then honor any configured mirror, sidestepping Maven Central rate limits (HTTP 404 + Retry-After) under parallel load. Gradle does not normally read the user's Maven settings, so this opt-in lives entirely in test sources of openrewrite/rewrite — not in any published API surface.
…imits Inlines the build job that previously delegated to openrewrite/gh-automation's reusable ci-gradle workflow, and adds an `s4u/maven-settings-action` step that writes a `~/.m2/settings.xml` with a wildcard mirror pointing at Moderne's Artifactory cache. The MavenSettingsAutoLoadingExtension introduced earlier in this PR loads that file into the test ExecutionContext, so recipes resolving Maven artifacts during rewrite-gradle tests no longer hit Maven Central directly and avoid the HTTP 404 + Retry-After throttling that's been failing CI under parallel load. The reusable workflow had no hook to inject extra setup steps, and inlining keeps everything in this PR. Functionality (build, scheduled-failure Slack notification, snapshot publish on main) is preserved.
…l rate limits" This reverts commit a4ba99a.
2 tasks
Switches from the gh-automation reusable workflow (`ci-gradle.yml`) to its finer-grained composite-action form, so we can inject `s4u/maven-settings-action` between `setup` and `build`. The action writes a `~/.m2/settings.xml` whose wildcard mirror points at Moderne's Artifactory cache; the MavenSettingsAutoLoadingExtension introduced earlier in this PR loads it into the test ExecutionContext, avoiding Maven Central's HTTP 404 + Retry-After throttling under parallel test load. The composite actions land in openrewrite/gh-automation#94.
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
RewriteTest.defaultExecutionContextCustomizers— aMap<Class<?>, Consumer<ExecutionContext>>applied to every defaultExecutionContext. Test-framework integrations (JUnit, TestNG, Spock, etc.) register a customizer keyed by their own class withoutrewrite-testtaking a dependency on the framework;putIfAbsentmakes registration naturally idempotent.BeforeAllCallbackinrewrite-gradle/src/test, auto-detected via service loader, that loads~/.m2/settings.xmlinto the ExecutionContext so Gradle tests honor any configured mirror.s4u/maven-settings-actioncan be slotted betweensetupandbuildand write a~/.m2/settings.xmlwhose wildcard mirror points at Moderne's Artifactory cache.Why
Recent
rewrite-gradle:testfailures onmainwereMavenPomDownloaderrequests being throttled by Maven Central / Cloudflare with HTTP 404 +Retry-Afterunder parallel test load. Routing artifact resolution through a configured mirror via~/.m2/settings.xmlbypasses the rate limit.Gradle does not normally read the user's Maven settings, so the loader is opt-in at the
rewrite-gradletest classpath only — nothing changes for downstream consumers oforg.openrewrite.gradle.Assertions.Test plan
./gradlew :rewrite-gradle:test --tests org.openrewrite.gradle.AddPlatformDependencyTest— 20/20 green locally with~/.m2/settings.xmlconfigured (was 8/20 failing without).rewrite-gradle:testandrewrite-java-test:testfailures clear with the workflow change.defaultExecutionContextbeing free of customizations (registry is empty until a framework integration opts in).