Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can maven handle custom qualifiers?

I'm trying to figure out if what Maven's policy is on custom qualifiers. I know that there exists specific qualifiers in Version strings that maven checks for, such as:

1.0.0-SNAPSHOT

5.3.0-beta-5

etc, but I was wondering if I could write specific rules or something that could handle custom qualifiers, such as:

1.0.0-mybranch

5.3.0-myotherbranch

or how maven would deal with such version strings. I've tried them out and things seem to be ok, I'm just wondering if Maven has some custom logic that could be used.

Thanks!

like image 662
DrakeAnderson Avatar asked Aug 15 '11 23:08

DrakeAnderson


2 Answers

These examples will work fine.

Qualifiers have no special meaning other than:

  • SNAPSHOT, which gets transformed into the correct timestamp / build number
  • solely numerical values, which are actually a build number instead of a qualifier (and considered newer than the corresponding base version)

All qualifiers are considered to be older than the associated release, i.e. 1.2-beta-1 < 1.2

Comparison of qualifiers is done as a string comparison. This behaviour can differ in Maven 2.x and Maven 3.x (in the former, 1.0-beta-10 < 1.0-beta-5, in the latter it behaves in the reverse as you'd expect).

like image 193
Brett Porter Avatar answered Oct 12 '22 02:10

Brett Porter


The 2011 answer is now obsolete in many important details. See the Javadoc on https://maven.apache.org/ref/3.3.9/maven-artifact/apidocs/org/apache/maven/artifact/versioning/ComparableVersion.html and the Wiki link there for the current version processing logic.

c.f. How does maven sort version numbers? for commentary on the Javadoc for ComparableVersion.

like image 26
user7610 Avatar answered Oct 12 '22 01:10

user7610