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

Caching, Last Version on XML reports, Remove Oldest #732

Merged
merged 1 commit into from
Oct 17, 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
6 changes: 3 additions & 3 deletions src/it/it-dependency-updates-report-001/verify.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ try
System.out.println( "Result = \"" + result +"\"" );
return false;
}
if ( result.indexOf( "1.1.1 Next Incremental" ) < 0)
if ( result.indexOf( "1.1.1" ) < 0)
{
System.out.println( "Did not identify next incremental" );
System.out.println( "Result = \"" + result +"\"" );
Expand All @@ -35,7 +35,7 @@ try
System.out.println( "Result = \"" + result +"\"" );
return false;
}
if ( result.indexOf( "1.2 Next Minor" ) < 0)
if ( result.indexOf( "1.2" ) < 0)
{
System.out.println( "Did not identify next minor version" );
System.out.println( "Result = \"" + result +"\"" );
Expand All @@ -47,7 +47,7 @@ try
System.out.println( "Result = \"" + result +"\"" );
return false;
}
if ( result.indexOf( "2.0 Next Major" ) < 0)
if ( result.indexOf( "2.0" ) < 0)
{
System.out.println( "Did not identify next major version" );
System.out.println( "Result = \"" + result +"\"" );
Expand Down
8 changes: 4 additions & 4 deletions src/it/it-dependency-updates-report-002/verify.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ try
// System.out.println( "Result = \"" + result +"\"" );
// return false;
// }
// if ( result.indexOf( "1.1.0-2 Next Version" ) < 0)
// if ( result.indexOf( "1.1.0-2" ) < 0)
// {
// System.out.println( "Did not identify next version" );
// System.out.println( "Result = \"" + result +"\"" );
// return false;
// }
// if ( result.indexOf( "1.1.1 Next Incremental" ) < 0)
// if ( result.indexOf( "1.1.1" ) < 0)
// {
// System.out.println( "Did not identify next incremental" );
// System.out.println( "Result = \"" + result +"\"" );
Expand All @@ -35,7 +35,7 @@ try
// System.out.println( "Result = \"" + result +"\"" );
// return false;
// }
// if ( result.indexOf( "1.2 Next Minor" ) < 0)
// if ( result.indexOf( "1.2" ) < 0)
// {
// System.out.println( "Did not identify next minor version" );
// System.out.println( "Result = \"" + result +"\"" );
Expand All @@ -47,7 +47,7 @@ try
// System.out.println( "Result = \"" + result +"\"" );
// return false;
// }
// if ( result.indexOf( "2.0 Next Major" ) < 0)
// if ( result.indexOf( "2.0" ) < 0)
// {
// System.out.println( "Did not identify next major version" );
// System.out.println( "Result = \"" + result +"\"" );
Expand Down
6 changes: 3 additions & 3 deletions src/it/it-plugin-updates-report-001/verify.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ try
return false;
}
if ( result.indexOf( "Group Id localhost Artifact Id dummy-maven-plugin Current Version 1.0 Newer versions 2.0 "
+ "Next Major 2.1 3.0 3.1 Latest Major" ) < 0)
+ "2.1 3.0 3.1 Latest Major" ) < 0)
{
System.out.println( "Did not identify plugin next versions" );
System.out.println( "Result = \"" + result +"\"" );
return false;
}
if ( result.indexOf( "Group Id localhost Artifact Id dummy-api Current Version 1.1 Classifier Type jar Newer "
+ "versions 1.1.0-2 Latest Subincremental 1.1.1 Next Incremental 1.1.1-2 1.1.2 1.1.3 Latest Incremental 1.2 Next "
+ "Minor 1.2.1 1.2.2 1.3 Latest Minor 2.0 Next Major 2.1 3.0 Latest Major" ) < 0)
+ "versions 1.1.0-2 Latest Subincremental 1.1.1 1.1.1-2 1.1.2 1.1.3 Latest Incremental 1.2 "
+ "1.2.1 1.2.2 1.3 Latest Minor 2.0 2.1 3.0 Latest Major" ) < 0)
{
System.out.println( "Did not identify dependency next versions" );
System.out.println( "Result = \"" + result +"\"" );
Expand Down
2 changes: 1 addition & 1 deletion src/it/it-plugin-updates-report-002/verify.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ try
return false;
}
if ( result.indexOf( "Group Id localhost Artifact Id dummy-maven-plugin Current Version 1.0 Newer versions 2.0 "
+ "Next Major 2.1 3.0 3.1 Latest Major" ) < 0)
+ "2.1 3.0 3.1 Latest Major" ) < 0)
{
System.out.println( "Did not identify plugin next versions" );
System.out.println( "Result = \"" + result +"\"" );
Expand Down
2 changes: 1 addition & 1 deletion src/it/it-plugin-updates-report-003/verify.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ try
return false;
}
if ( result.indexOf( "Group Id localhost Artifact Id dummy-maven-plugin Current Version 1.0 Newer versions 2.0 "
+ "Next Major 2.1 3.0 3.1 Latest Major" ) < 0)
+ "2.1 3.0 3.1 Latest Major" ) < 0)
{
System.out.println( "Did not identify plugin next versions" );
System.out.println( "Result = \"" + result +"\"" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,51 +274,6 @@ public final ArtifactVersion[] getNewerVersions( String versionString, Optional<
return getVersions( restriction, includeSnapshots );
}

@Override
public final ArtifactVersion getOldestVersion( VersionRange versionRange, boolean includeSnapshots )
{
return getOldestVersion( versionRange, null, includeSnapshots );
}

@Override
public final ArtifactVersion getOldestVersion( Restriction restriction,
boolean includeSnapshots )
{
return getOldestVersion( null, restriction, includeSnapshots );
}

@Override
public final ArtifactVersion getOldestVersion( VersionRange versionRange, Restriction restriction,
boolean includeSnapshots )
{
ArtifactVersion oldest = null;
final VersionComparator versionComparator = getVersionComparator();
for ( ArtifactVersion candidate : getVersions( includeSnapshots ) )
{
if ( versionRange != null && !ArtifactVersions.isVersionInRange( candidate, versionRange ) )
{
continue;
}
if ( restriction != null && !isVersionInRestriction( restriction, candidate ) )
{
continue;
}
if ( !includeSnapshots && ArtifactUtils.isSnapshot( candidate.toString() ) )
{
continue;
}
if ( oldest == null )
{
oldest = candidate;
}
else if ( versionComparator.compare( oldest, candidate ) > 0 )
{
oldest = candidate;
}
}
return oldest;
}

@Override
public final ArtifactVersion[] getVersions( Restriction restriction, boolean includeSnapshots )
{
Expand Down Expand Up @@ -350,21 +305,6 @@ public final ArtifactVersion[] getVersions( VersionRange versionRange, Restricti
return result.toArray( new ArtifactVersion[0] );
}

@Override
public final ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, Optional<Segment> updateScope,
boolean includeSnapshots )
{
try
{
return getOldestVersion( getVersionComparator().restrictionFor( currentVersion, updateScope ),
includeSnapshots );
}
catch ( InvalidSegmentException e )
{
return null;
}
}

@Override
public final ArtifactVersion getNewestUpdate( ArtifactVersion currentVersion, Optional<Segment> updateScope,
boolean includeSnapshots )
Expand Down Expand Up @@ -395,12 +335,6 @@ public final ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Op
}
}

@Override
public final ArtifactVersion getOldestUpdate( Optional<Segment> updateScope )
{
return getOldestUpdate( updateScope, isIncludeSnapshots() );
}

@Override
public final ArtifactVersion getNewestUpdate( Optional<Segment> updateScope )
{
Expand All @@ -413,16 +347,6 @@ public final ArtifactVersion[] getAllUpdates( Optional<Segment> updateScope )
return getAllUpdates( updateScope, isIncludeSnapshots() );
}

@Override
public final ArtifactVersion getOldestUpdate( Optional<Segment> updateScope, boolean includeSnapshots )
{
if ( isCurrentVersionDefined() )
{
return getOldestUpdate( getCurrentVersion(), updateScope, includeSnapshots );
}
return null;
}

@Override
public final ArtifactVersion getNewestUpdate( Optional<Segment> updateScope, boolean includeSnapshots )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.apache.commons.lang3.tuple.Pair;

/**
* Utility providing a cached {@link ArtifactVersions#getOldestUpdate(Optional)} API
* Utility providing a cached {@link ArtifactVersions#getNewestUpdate(Optional)} API
*/
public class ArtifactVersionsCache
{
Expand Down
73 changes: 0 additions & 73 deletions src/main/java/org/codehaus/mojo/versions/api/VersionDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,53 +287,6 @@ ArtifactVersion[] getNewerVersions( String versionString, Optional<Segment> uppe
boolean includeSnapshots, boolean allowDowngrade )
throws InvalidSegmentException;

/**
* Returns the oldest version within the specified version range or <code>null</code> if no such version exists.
*
* @param versionRange The version range within which the version must exist.
* @param includeSnapshots <code>true</code> if snapshots are to be included.
* @return the oldest version between currentVersion and upperBound or <code>null</code> if no version is available.
* @since 1.0-beta-1
*/
ArtifactVersion getOldestVersion( VersionRange versionRange, boolean includeSnapshots );

/**
* Returns the oldest version within the specified bounds or <code>null</code> if no such version exists.
*
* @param restriction version criteria.
* @param includeSnapshots <code>true</code> if snapshots are to be included.
* @return the oldest version between lowerBound and upperBound or <code>null</code> if no version is available.
* @since 1.0-beta-1
*/
ArtifactVersion getOldestVersion( Restriction restriction, boolean includeSnapshots );

/**
* Returns the oldest version within the specified bounds or <code>null</code> if no such version exists.
*
* @param versionRange The version range within which the version must exist where <code>null</code> imples
* <code>[,)</code>.
* @param restriction version criteria.
* @param includeSnapshots <code>true</code> if snapshots are to be included.
* @return the oldest version between lowerBound and upperBound or <code>null</code> if no version is available.
* @since 1.0-beta-1
*/
ArtifactVersion getOldestVersion( VersionRange versionRange, Restriction restriction, boolean includeSnapshots );

/**
* Returns the oldest version newer than the specified current version, but within the specified update scope or
* <code>null</code> if no such version exists.
*
* @param currentVersion the lower bound or <code>null</code> if the lower limit is unbounded.
* @param updateScope the update scope to include.
* @param includeSnapshots <code>true</code> if snapshots are to be included.
* @return the oldest version after currentVersion within the specified update scope or <code>null</code> if no
* version is available.
* @throws InvalidSegmentException thrown if the updateScope is greater than the number of segments
* @since 1.0-beta-1
*/
ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, Optional<Segment> updateScope,
boolean includeSnapshots ) throws InvalidSegmentException;

/**
* Returns the all versions newer than the specified current version, but within the specified update scope.
*
Expand All @@ -347,18 +300,6 @@ ArtifactVersion getOldestUpdate( ArtifactVersion currentVersion, Optional<Segmen
ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Optional<Segment> updateScope,
boolean includeSnapshots ) throws InvalidSegmentException;

/**
* Returns the oldest version newer than the current version, but within the specified update scope or
* <code>null</code> if no such version exists.
*
* @param updateScope the update scope to include.
* @return the oldest version after currentVersion within the specified update scope or <code>null</code> if no
* version is available.
* @throws InvalidSegmentException thrown if the updateScope is greater than the number of segments
* @since 1.0-beta-1
*/
ArtifactVersion getOldestUpdate( Optional<Segment> updateScope ) throws InvalidSegmentException;

/**
* Returns the newest version newer than the specified current version, but within the specified update scope or
* <code>null</code> if no such version exists.
Expand All @@ -381,20 +322,6 @@ ArtifactVersion[] getAllUpdates( ArtifactVersion currentVersion, Optional<Segmen
*/
ArtifactVersion[] getAllUpdates( Optional<Segment> updateScope ) throws InvalidSegmentException;

/**
* Returns the oldest version newer than the specified current version, but within the specified update scope or
* <code>null</code> if no such version exists.
*
* @param updateScope the update scope to include.
* @param includeSnapshots <code>true</code> if snapshots are to be included.
* @return the oldest version after currentVersion within the specified update scope or <code>null</code> if no
* version is available.
* @throws InvalidSegmentException thrown if the updateScope is greater than the number of segments
* @since 1.0-beta-1
*/
ArtifactVersion getOldestUpdate( Optional<Segment> updateScope, boolean includeSnapshots )
throws InvalidSegmentException;

/**
* Returns the newest version newer than the specified current version, but within the specified update scope or
* <code>null</code> if no such version exists.
Expand Down