I maintain an open source project and publish its releases to The Central Repository. I just published oshi-core-2.6
. The versioning in my pom.xml
for that release reads:
<groupId>com.github.dblock</groupId>
<artifactId>oshi-core</artifactId>
<version>2.6</version>
My code requires Java 8 due to the Date/Time functions. To support a user's request, just prior to this release, I released a Java 7 compatible version using the threeten backport, with the following in its pom.xml
:
<groupId>com.github.dblock</groupId>
<artifactId>oshi-core</artifactId>
<version>2.6-m-java7</version>
How Version Numbers Work in Maven states that "All versions with a qualifier are older than the same version without a qualifier (release version)." Another StackOverflow question, How does maven sort version numbers?, has an answer citing the ComparableVersion class which lists several well-known qualifiers (alpha, beta, milestone, rc, and snapshot) which are supposed to sort "earlier" than the ga/final (empty string) release.
Having been bit by having a custom qualifier in an earlier version, I tried to use the milestone qualifier (-m-
) in my java7 version to indicate to Maven that it should be an "earlier" release than 2.6. However, searching the Central Repository shows that the -m-
version is the "Latest Version".
Questions I have:
- Why does the Central Repository sorting not match the documented sorting I've linked above?
- Is it using an earlier version (pre-3.2) of Maven's sorting? If so, what consistent "Latest Version" sorting can I expect?
- Does the hyphen in my artifact name have any impact?
- Is there a better way of releasing the same version number in two formats than the way I have (obviously poorly) chosen?