Skip to content

fix: use maven-metadata.xml to look up latest test framework version#1868

Open
wenytang-ms wants to merge 1 commit into
mainfrom
fix/use-maven-metadata-for-version
Open

fix: use maven-metadata.xml to look up latest test framework version#1868
wenytang-ms wants to merge 1 commit into
mainfrom
fix/use-maven-metadata-for-version

Conversation

@wenytang-ms
Copy link
Copy Markdown
Contributor

Summary

Enable Java Tests currently looks up the latest framework version through search.maven.org's Solr API and reads the latestVersion field. That index has been frozen since around May 2025 (a side effect of Sonatype migrating Central to central.sonatype.com), so the response is stale.

Concretely, for org.junit.platform:junit-platform-console-standalone the endpoint returns:

{ "response": { "docs": [ { "latestVersion": "1.13.0-M3", ... } ] } }

while Maven Central actually serves stable versions up to 1.14.4 (Platform 1.x line) and 6.1.0 (Platform 6 line, maven-metadata.xml). The user-visible effect is the symptom reported in #1866 — the command downloads 1.13.0-M3 (a JUnit 5 milestone) or, after the fall-back, the hard-coded 1.9.3.

Change

Switch the lookup to repo1.maven.org/.../maven-metadata.xml, which is the artifact's own metadata file and is always current:

  1. Prefer the <release> tag (Maven's pointer to the latest non-snapshot version).
  2. If that is missing or itself a pre-release, scan <version> entries from newest to oldest for the first stable build.
  3. Filter pre-release qualifiers (-M*, -RC*, -beta, -SNAPSHOT, …) via a simple ^\d+(\.\d+)*$ check.

Also bump the JUnit Jupiter defaultVersion fallback from 1.9.3 to 6.1.0 so the offline path matches a currently published stable.

Verification

Manual end-to-end:

  • Enable Java Tests → JUnit Jupiter now downloads junit-platform-console-standalone-6.1.0.jar (was 1.13.0-M3 or 1.9.3).
  • With network disabled, the offline fallback writes …-6.1.0.jar.
  • npm run lint and npm run compile clean.

Notes

Related to #1866

The previous implementation queried search.maven.org's Solr endpoint and
returned the `latestVersion` field. That index has been frozen since
around May 2025 (a side effect of the Sonatype migration to
central.sonatype.com), so the endpoint now serves stale data. For
example, the latest version it reports for
`junit-platform-console-standalone` is `1.13.0-M3` (a JUnit 5 milestone),
while the actual current stable on Maven Central is `6.1.0`. As a
result, `Enable Java Tests` ends up downloading either that milestone
or, after falling back, the hard-coded `1.9.3`.

Switch the lookup to the artifact's own `maven-metadata.xml` on
repo1.maven.org, which is the authoritative metadata maintained
alongside the artifact:

* Prefer the `<release>` tag (Maven's pointer to the latest non-snapshot
  version).
* Fall back to scanning `<version>` entries from newest to oldest for
  the first stable build.
* Pre-release qualifiers (`-M*`, `-RC*`, `-beta`, `-SNAPSHOT`, etc.) are
  rejected via `isStableVersion`.

Also bump the JUnit Jupiter `defaultVersion` from `1.9.3` to `6.1.0` so
the offline fallback matches a currently published stable.

Related to #1866

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant