J Fabian Meier
J Fabian Meier

Reputation: 35903

Understanding Maven Version Ranges

Assume that I have an artifact with versions

1.0-SNAPSHOT, 1.0, 1.1, 1.2-SNAPSHOT

in my Maven repository. Now, when I specify a version range

[1.0-SNAPSHOT,)

for this artifact (and assume there are no other version requirements), will Maven resolve it to 1.1 or 1.2-SNAPSHOT?

I have read that version ranges resolve to release versions if both boundaries are release versions but haven't understood the exact behaviour if one of the boundaries is a SNAPSHOT.

Background: For some legacy reasons, we have release artifacts which depend on SNAPSHOT artifacts. These SNAPSHOT artifacts are removed when a release version is available (which breaks Maven builds). Logically, I am aiming for the behaviour: Take the SNAPSHOT version, but replace it with a release version as soon as one is available.

Upvotes: 4

Views: 2439

Answers (1)

Dominik Vincenz
Dominik Vincenz

Reputation: 435

I just tested, maven resolved it to 1.2-SNAPSHOT

So the priority seems to be:

  1. Look for the latest version (1.2)
  2. Take Release if available. Else SNAPSHOT

Upvotes: 2

Related Questions