Home

Version numbers in Maven

This memo explains the Apache Maven 3 version number schema.

Structure

The Apache Maven 3 version schema has 5 properties.

  1. Major version
  2. Minor version
  3. Incremental version
  4. Build number
  5. A Qualifier

Format: MajorVersion [ . MinorVersion [ . IncrementalVersion ] ] [ - BuildNumber | Qualifier ]

Where MajorVersion, MinorVersion, IncrementalVersion and BuildNumber are all numeric and Qualifier is a string.

If your version number does not match this format, then the entire version number is treated as being the Qualifier.

Ordering Rules

1. All versions with a qualifier are older than the same version without a qualifier

For example: 5.14-SNAPSHOT is older than 5.14.

assertOlderThen "5.14-SNAPSHOT", "5.14"

2. Identical versions with different qualifier fields are compared by using basic string comparison

For example: 5.14-beta-2 is newer than 5.14-alpha-6.

assertNewerThen "5.14-beta-2", "5.14-alpha-6"

3. Versions are case insensitive

Internally all version strings are transformed to lower case. (With java.lang.String#toLowerCase(Locale.ENGLISH))

assertEquals "5.14-HELLO-SNAPSHOT", "5.14-hello-snapshot"

4. '-' (dash) and '.' (dot) separators can be mixed

It does't matter if you use a dash or a dot to separate the version properties.

assertEquals "1.0", "1-0" // (1) == (1)
assertEquals "1-0.0", "1.0-0"  // (1) == (1)

5. A dash is always less important than something preceded with a dot

assertOlderThen "1-2", "1.2" // (1,(2)) < (1,2)
assertOlderThen "1.1.1-1.1", "1.1.1.1-1.1" // (1,1,1,(1,1)) < (1,1,1,1,(1,1))

6. Transition between characters and digits also constitutes a separator

assertEquals "1.0alpha1", "1.0.alpha-1"

7. Version components in the text can be digits or strings

assertOlderThen "a.2.a", "a.2.b" // (a,2,a) < (a,2,b)
assertOlderThen "a.a.a-SNAPSHOT", "a.a.b" // (a,a,a,snapshot) < (a,a,b)
assertEquals "a.a.a", "a.a.a" // (a,a,a) == (a,a,a)
assertNewerThen "a.z.a", "a.a.a" // (a,z,a) > (a,a,a)

Special Qualifiers

Maven versions can contain special qualifiers.

assertEquals '1ga', '1final'
assertEquals "1-0.0.GA", "1-0.0-final"
assertEquals '1ga', '1'
assertEquals "1final", "1"
assertEquals "1cr", "1rc"
assertEquals "1a1", "1alpha1"
assertEquals "1b2", "1beta2"
assertEquals "1m3", "1milestone3"

References

  1. http://maven.apache.org/ref/3.0.5/maven-artifact/apidocs/org/apache/maven/artifact/versioning/ComparableVersion.html
  2. http://mojo.codehaus.org/versions-maven-plugin/version-rules.html
  3. http://docs.codehaus.org/display/MAVEN/Versioning
  4. https://git-wip-us.apache.org/repos/asf?p=maven.git;a=blob;f=maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ArtifactVersion.java;hb=HEAD
  5. http://docs.oracle.com/middleware/1212/core/MAVEN/maven_version.htm

Date published:
Date modified: 2014-09-01
Keywords: Maven, Versioning