Skip to content

[maven-4.0.x] Use maven-api Version for mvnup plugin version comparison#12073

Merged
gnodet merged 1 commit into
maven-4.0.xfrom
fix-milestone-version-comparison-4.0.x
May 19, 2026
Merged

[maven-4.0.x] Use maven-api Version for mvnup plugin version comparison#12073
gnodet merged 1 commit into
maven-4.0.xfrom
fix-milestone-version-comparison-4.0.x

Conversation

@gnodet
Copy link
Copy Markdown
Contributor

@gnodet gnodet commented May 18, 2026

Summary

Backport of #12072 to maven-4.0.x.

Replace the hand-rolled version comparison in PluginUpgradeStrategy.isVersionBelow() with Session.parseVersion() from maven-api, which correctly handles milestone/pre-release qualifiers.

Problem

The previous implementation stripped qualifiers before comparison:

String cleanCurrent = currentVersion.split("-")[0]; // "3.0.0-M1" → "3.0.0"

This caused isVersionBelow("3.0.0-M1", "3.0.0") to return false — mvnup thought 3.0.0-M1 was already sufficient when it's actually a pre-release below 3.0.0.

This affected 19 projects in maven4-testing (16 flink-connectors + 3 sling projects) using maven-enforcer-plugin:3.0.0-M1, which is incompatible with Maven 4.

Fix

Use Session.parseVersion() from maven-api which returns a Comparable<Version> that correctly handles all version qualifier semantics:

  • 3.0.0-M1 < 3.0.0
  • 3.0.0-alpha-1 < 3.0.0
  • 3.0.0-RC1 < 3.0.0
  • 3.0.0-SNAPSHOT < 3.0.0

Test plan

  • All existing tests pass (22/22)
  • New test: shouldUpgradeMilestoneVersionBelowRelease — verifies 3.0.0-M1 is upgraded to 3.0.0

Claude Code on behalf of Guillaume Nodet

Replace hand-rolled version comparison with Session.parseVersion() which
correctly handles milestone/pre-release qualifiers. The previous
implementation stripped qualifiers (e.g., 3.0.0-M1 → 3.0.0) causing
pre-release versions to be incorrectly considered sufficient.

This fixes 19 projects (flink-connectors, sling) using enforcer
3.0.0-M1 that mvnup failed to upgrade to 3.0.0.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gnodet gnodet force-pushed the fix-milestone-version-comparison-4.0.x branch from f7c482b to 2631458 Compare May 19, 2026 09:05
@gnodet gnodet changed the title Use maven-api Version for mvnup plugin version comparison [maven-4.0.x] Use maven-api Version for mvnup plugin version comparison May 19, 2026
@gnodet gnodet added this to the 4.0.0-rc-6 milestone May 19, 2026
@gnodet gnodet merged commit 0a792e8 into maven-4.0.x May 19, 2026
23 checks passed
@gnodet gnodet deleted the fix-milestone-version-comparison-4.0.x branch May 19, 2026 14:28
@github-actions
Copy link
Copy Markdown

@gnodet Please assign appropriate label to PR according to the type of change.

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.

2 participants