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

#632 Second batch of maintenance following PR #672 #711

Merged
merged 2 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import org.codehaus.mojo.versions.api.PomHelper;
import org.codehaus.mojo.versions.api.Segment;
import org.codehaus.mojo.versions.ordering.InvalidSegmentException;
import org.codehaus.mojo.versions.ordering.MajorMinorIncrementalFilter;
import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader;
import org.codehaus.mojo.versions.utils.DependencyBuilder;

Expand Down Expand Up @@ -151,8 +150,6 @@ private void useLatestReleases( ModifiedPomXMLEventReader pom, Collection<Depend
{
Optional<Segment> unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates,
allowIncrementalUpdates );
MajorMinorIncrementalFilter majorMinorIncfilter =
new MajorMinorIncrementalFilter( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates );

for ( Dependency dep : dependencies )
{
Expand Down Expand Up @@ -185,10 +182,9 @@ private void useLatestReleases( ModifiedPomXMLEventReader pom, Collection<Depend
ArtifactVersions versions = getHelper().lookupArtifactVersions( artifact, false );
try
{
ArtifactVersion[] newer = versions.getNewerVersions( version, unchangedSegment, false );
newer = filterVersionsWithIncludes( newer, artifact );

ArtifactVersion[] filteredVersions = majorMinorIncfilter.filter( selectedVersion, newer );
// TODO consider creating a search + filter in the Details services to get latest release.
ArtifactVersion[] newer = versions.getNewerVersions( version, unchangedSegment, false, false );
ArtifactVersion[] filteredVersions = filterVersionsWithIncludes( newer, artifact );
if ( filteredVersions.length > 0 )
{
String newVersion = filteredVersions[filteredVersions.length - 1].toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import org.codehaus.mojo.versions.api.PomHelper;
import org.codehaus.mojo.versions.api.Segment;
import org.codehaus.mojo.versions.ordering.InvalidSegmentException;
import org.codehaus.mojo.versions.ordering.MajorMinorIncrementalFilter;
import org.codehaus.mojo.versions.ordering.VersionComparator;
import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader;
import org.codehaus.mojo.versions.utils.DependencyBuilder;
Expand Down Expand Up @@ -151,8 +150,6 @@ private void useLatestSnapshots( ModifiedPomXMLEventReader pom, Collection<Depen
{
Optional<Segment> unchangedSegment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates,
allowIncrementalUpdates );
MajorMinorIncrementalFilter majorMinorIncfilter =
new MajorMinorIncrementalFilter( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates );

for ( Dependency dep : dependencies )
{
Expand Down Expand Up @@ -201,6 +198,7 @@ private void useLatestSnapshots( ModifiedPomXMLEventReader pom, Collection<Depen
ArtifactVersion[] newer = versions.getVersions( restriction, true );
getLog().debug( "Candidate versions " + Arrays.asList( newer ) );

// TODO consider creating a search + filter in the Details services to get latest snapshot.
String latestVersion;
ArrayList<ArtifactVersion> snapshotsOnly = new ArrayList<>();

Expand All @@ -212,13 +210,8 @@ private void useLatestSnapshots( ModifiedPomXMLEventReader pom, Collection<Depen
snapshotsOnly.add( artifactVersion );
}
}
getLog().debug( "Snapshot Only versions " + snapshotsOnly );

ArtifactVersion[] filteredVersions = majorMinorIncfilter.filter(
selectedVersion, snapshotsOnly.toArray( new ArtifactVersion[0] ) );
getLog().debug( "Filtered versions " + Arrays.asList( filteredVersions ) );


ArtifactVersion[] filteredVersions = snapshotsOnly.toArray(
new ArtifactVersion[snapshotsOnly.size()] );
if ( filteredVersions.length > 0 )
{
latestVersion = filteredVersions[filteredVersions.length - 1].toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ private void useLatestVersions( ModifiedPomXMLEventReader pom, Collection<Depend

try
{
// TODO consider creating a getNewestVersion method in the Details services.
ArtifactVersion[] newerVersions = versions.getNewerVersions( version, unchangedSegment, allowSnapshots,
allowDowngrade );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ public final ArtifactVersion[] getNewerVersions( String versionString, Optional<
: getVersionComparator().incrementSegment( lowerBound, upperBoundSegment.get() );

Restriction restriction = new Restriction( lowerBound, allowDowngrade, upperBound, allowDowngrade );
// TODO shouldn't allowDowngrade boolean be passed to this call ?
return getVersions( restriction, includeSnapshots );
}

Expand Down