Skip to content

Commit

Permalink
Second batch of maintenance following PR #672
Browse files Browse the repository at this point in the history
  • Loading branch information
sultan committed Sep 28, 2022
1 parent b5edfe0 commit e87bdbd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 23 deletions.
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 @@ -45,7 +45,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 @@ -167,8 +166,6 @@ private void useLatestVersions( 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 @@ -199,10 +196,10 @@ private void useLatestVersions( ModifiedPomXMLEventReader pom, Collection<Depend

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

ArtifactVersion[] filteredVersions = majorMinorIncfilter.filter( selectedVersion, newerVersions );
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 @@ -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

0 comments on commit e87bdbd

Please sign in to comment.