Skip to content
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

Use ComparableVersion from Maven and remove the duplicate #898

Merged

Conversation

andrzejj0
Copy link
Contributor

Removing the duplicated ComparableVersion, which is also present in Maven.

Because it's removed, I had to rework BoundArtifactVersion a bit. Now it's not "hacking" ComparableVersion anymore, ie, it's no longer using its private implementation to compute compareTo(). Instead, it's construction "infinity-like" version by using Integer.MAX_INT and uses this to do the comparison on the standard DefaultArtifactVersion.

BoundArtifactVersion is also officially, contractually immutable, and because of that, its parseVersion method throws an exception and is deprecated.

Also, because the ComparableVersion is gone, the cache is also gone, so I've implemented our own, but went a bit further: we're caching DefaultArtifactVersion instead, since it's also (almost) immutable, and we're not using it's only mutating method parseVersion() anywhere.

On this condition, it's safe to use the cache.

@andrzejj0
Copy link
Contributor Author

@slawekjaranowski please review.

* @param artifactVersion version in a text format
* @param segment most major segment that can change, i.e. <em>not</em> held in place
*/
public BoundArtifactVersion(String artifactVersion, Segment segment) {
Copy link
Contributor Author

@andrzejj0 andrzejj0 Jan 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is the key method, I guess...

Hope this is clear, looks a bit like first year's comp-sci exercise, but we're simply parsing the version and splitting it to tokens upon:

  • a change from numbers to letters or vice-versa
  • an - character
  • a dot

The newly constructed version will have Inetger.MAX_VALUE on all places less than the fixed segment. Also, all non-strandard tokens will be replaced by zeros (like in the old impl).

@andrzejj0
Copy link
Contributor Author

@slawekjaranowski please review

@slawekjaranowski slawekjaranowski added this to the 2.15.0 milestone Jan 15, 2023
@slawekjaranowski slawekjaranowski merged commit 0893ebd into mojohaus:master Jan 15, 2023
@andrzejj0 andrzejj0 deleted the remove-comparable-version branch January 16, 2023 05:10
srowen pushed a commit to apache/spark that referenced this pull request Mar 3, 2023
### What changes were proposed in this pull request?
This pr aims upgrade `versions-maven-plugin` to 2.15.0

### Why are the changes needed?
New version bring some improvements like:
- mojohaus/versions#898
- mojohaus/versions#883
- mojohaus/versions#878
- mojohaus/versions#893

and some bug fix:
- mojohaus/versions#901
- mojohaus/versions#897
- mojohaus/versions#891

The full release notes as follows:
- https://github.com/mojohaus/versions/releases/tag/2.15.0

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?

- GA `Dependencies test` should work normally
- Manually check `./dev/test-dependencies.sh --replace-manifest`, run successful

Closes #40248 from LuciferYang/SPARK-42648.

Authored-by: yangjie01 <yangjie01@baidu.com>
Signed-off-by: Sean Owen <srowen@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants