Skip to content

Keep DependencyListTest and ModuleHasDependencyTest from asking Maven Central directly - #207

Merged
jkschneider merged 1 commit into
mainfrom
jkschneider/tests-reach-central-through-mirror
Oct 25, 2026
Merged

jkschneider merged 1 commit into
mainfrom
jkschneider/tests-reach-central-through-mirror

Conversation

@jkschneider

@jkschneider jkschneider commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

The Code Genome Project builds this repository with MAVEN_CENTRAL_MIRROR_URL, _USERNAME and _PASSWORD naming a mirror, and Maven settings that mirror everything through it. Since #206, two tests there still reached repo.maven.apache.org directly, one connection each.

  • DependencyListTest#validateResolvable gives the recipe an LST whose only repository, https://nonexistent, can't be reached. Its xml() source loads no Maven settings, and the downloader adds Maven Central behind that repository, so the test asked Central for com/test/test/maven-metadata.xml and its directory listing, and got 404s. Its context now leaves out Central and the local repository, so the pretend repository is the only one asked. The recipe still reports the MavenDownloadingException the test checks for.
  • ModuleHasDependencyTest.WhenDependencyIsRequestedButNotResolved#mavenMatchesOnRequested forced empty settings, which keep the machine's own out but name no mirror, so spring-beans 6.0.0 and the POMs it needs came from Central directly. Like DependencyResolutionDiagnosticTest#maven since Check the diagnostic's report without naming Maven Central's or the plugin portal's URL #206, it now uses settings that mirror only Central through MAVEN_CENTRAL_MIRROR_URL when that is set, and the same empty settings when it is not. settingsMirroringOnlyCentral moves from DependencyResolutionDiagnosticTest to MavenCentralMirror, unchanged, so that both tests can use it.

Locally, against the Code Genome Project's current snapshots, DependencyListTest, ModuleHasDependencyTest and DependencyResolutionDiagnosticTest pass with and without MAVEN_CENTRAL_MIRROR_* set, 48 tests each. I also recorded every socket read and write of the test JVMs with Java Flight Recorder while those classes ran with the mirror set:

  • On main, validateResolvable and mavenMatchesOnRequested each opened a connection to repo.maven.apache.org.
  • With this change, every read and write the three classes make to another machine goes to the mirror. validateResolvable makes none at all.

With no mirror named, mavenMatchesOnRequested still reaches Central directly, as before.

… Central directly

Where CI names a mirror, as the Code Genome Project's builds do, two tests still reached
repo.maven.apache.org directly.

DependencyListTest#validateResolvable gives the recipe an LST whose only repository can't be
reached. Its xml() source loads no Maven settings, and the downloader adds Maven Central behind that
repository, so the test asked Central for com/test/test/maven-metadata.xml and its directory
listing, and got 404s. Its context now leaves out Central and the local repository, so the pretend
repository is the only one asked. The recipe still reports the MavenDownloadingException the test
checks for.

ModuleHasDependencyTest.WhenDependencyIsRequestedButNotResolved#mavenMatchesOnRequested forced empty
settings, which keep the machine's own out but name no mirror, so spring-beans 6.0.0 and the POMs it
needs came from Central directly. Like DependencyResolutionDiagnosticTest#maven since #206, it now
uses settings that mirror only Central through MAVEN_CENTRAL_MIRROR_URL, _USERNAME and _PASSWORD
when they are set, and the same empty settings when they are not. settingsMirroringOnlyCentral moves
from DependencyResolutionDiagnosticTest to MavenCentralMirror so that both tests can use it.
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Oct 25, 2026
@jkschneider
jkschneider merged commit c51907b into main Oct 25, 2026
2 checks passed
@jkschneider
jkschneider deleted the jkschneider/tests-reach-central-through-mirror branch October 25, 2026 00:43
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant