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

Correcting BoundArtifact comparison and eliminating incrementSegment #771

Merged

Conversation

jarmoniuk
Copy link
Contributor

@jarmoniuk jarmoniuk commented Oct 19, 2022

So, I examined BoundArtifactVersion and especially the comparison and tried to rule out/handle all corner cases I could imagine.

The premise for that was that we were still using "-snapshot" to construct the lower bound such that all other versions would naturally (using how the current implementation of the Maven comparison works) be compared as more major. I didn't think this was good enough and implemented the same using BoundArtifact.

So, my idea was to, instead using "-SNAPSHOT" to denote the lowest possible version on a given segment, use a BoundArtifact representing an upper bound on the less major segment.

So, instead of 1.0.0-SNAPSHOT to denote the least possible version of "1.0.0", we could use something like 0.9.9-(infinity) to achieve the same (so, "attack" from the other side).

Because we're not actually using the incrementSegment method anymore, I removed that method. The ideal goal would be to make the "Comparator" classes actually implement the interface only, and not do auxiliary things like count segments. But that was not my goal here.

This obviously does not need to go into the upcoming release. I've tested it, but maybe we should test it a bit more.

return compareTo( ( (List<Item>) items ).iterator(),
( (Iterable<Item>) o.items ).iterator(), artifactVersion.segment.value() );

}

@SuppressWarnings( "checkstyle:InnerAssignment" )
private int compareTo( Iterator<Item> left, Iterator<Item> right, int comparisonLimit )
private int compareTo( Iterator<Item> left, Iterator<Item> right, int comparisonsLeft )
Copy link
Contributor Author

@jarmoniuk jarmoniuk Oct 19, 2022

Choose a reason for hiding this comment

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

This is the central part of this PR.

@jarmoniuk jarmoniuk changed the title Correcting BoundArtifactComparison and eliminating incrementSegment Correcting BoundArtifact comparison and eliminating incrementSegment Oct 19, 2022
@sultan
Copy link
Contributor

sultan commented Oct 20, 2022

Tested your branch, All HTML Reports looks good to me. Great job!

@jarmoniuk
Copy link
Contributor Author

In that case I would consider it for the upcoming release. @slawekjaranowski what do you think?

@sultan
Copy link
Contributor

sultan commented Oct 22, 2022

+1! I would go with release your code instead of my "increment forces snapshot"

@slawekjaranowski slawekjaranowski added this to the 2.13.0 milestone Oct 23, 2022
@slawekjaranowski slawekjaranowski merged commit de4ec66 into mojohaus:master Oct 23, 2022
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.

None yet

3 participants