-
Notifications
You must be signed in to change notification settings - Fork 267
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
Refactoring: coalesce use-*-* goals. #1202
base: master
Are you sure you want to change the base?
Conversation
8f73fdf
to
18c7590
Compare
versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/UseLatestVersionsMojo.java
Outdated
Show resolved
Hide resolved
|
||
@Override | ||
protected boolean isAllowSnapshots() { | ||
return true; |
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.
why such ...
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.
This is called by a method from the base class, UseLatestVersionsMojoBase#update so that it selects snapshots -- we are looking for snapshots to upgrade to:
Optional<ArtifactVersion> newestVer = versionProducer(Arrays.stream(versions.getNewerVersions(
dep.getVersion(), unchangedSegment, isAllowSnapshots(), isAllowDowngrade()))
.filter(this::artifactVersionsFilter));
So, to make this execution universal and common to different sorts of "use-*-*", the method in the base class uses those callback methods.
As an alternative, this could be done using composition and an object having those parameters (allowSnaphots) as its constructor parameters.
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.
The property allowSnapshots
doesn't make sense in some of the goals, like this one (because here we are only interested in snapshots, so we must allow them), so I'll push the property down the class hierarchy to goals where it does make sense. At the same time, I'll pull isAllowSnapshots()
upwards as an abstract method.
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.
Please note that I'm doing this in stages so that the PR doesn't grow too big.
18c7590
to
46c42c3
Compare
46c42c3
to
5d6e682
Compare
I wanted to try and do something similar to what #292 was, but since the plugin has moved on, it first needs some refactoring.
This PR makes the use-*-* goals use shared codebase in order to make future refactoring simpler.