-
Notifications
You must be signed in to change notification settings - Fork 327
Maven version parse xml rather than html #2665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maven version parse xml rather than html #2665
Conversation
eyalkoren
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do like the parsing and testing touches, but I think relying on suffix for ordering is not solid.
While this is obvious:
Version.of(1.2.3-SNAPSHOT).equals(Version.of(1.2.3-RC0)) == false
This is just arbitrary:
Version.of(1.2.3-SNAPSHOT).compareTo(Version.of(1.2.3-RC0)) </> 0
The problem is that making those inconsistent could cause trouble specifically in sorted sets (see the Comparable javadoc).
Note that the parsing logic we have now in Version is not necessarily about identifying version prefixes and suffixes as you think about them, but a way to extract the version part out of a string, for example, such that comes from a jar manifest. The redhat httpclient example is real.
Bottom line, I think it's best to make both equality check and ordering rely only on the version numbers, but still maintain the hasSuffix and use it as you already did.
apm-agent-common/src/test/java/co/elastic/apm/agent/util/VersionTest.java
Outdated
Show resolved
Hide resolved
apm-agent-common/src/main/java/co/elastic/apm/agent/util/Version.java
Outdated
Show resolved
Hide resolved
I don't quite get this part as the sort is consistent with equals. While 1.2.3-SNAPSHOT > 1.2.3-RC0 may be arbitrary, it is consistent. But yeah, overall it seems it doesn't quite work out due to the |
Sorry for not being clear enough. IMO, the best way to reflect versioning equality/comparison logic is: However, I think we should avoid that due to the inconsistency issue. |
|
Gotcha, I created a method that lets you remove suffixes. I think that's the best of both worlds. We can ignore suffixes in the element matcher where we know we have to deal with unorthodox |
|
/test |
1 similar comment
|
/test |
Consider the second commit optional. I can remove it if you don't like it.