Search code examples
mavenqualifiers

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!


Solution

  • 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).