From 94c24efc5c6999b648c872f21dbb698c2d9868d6 Mon Sep 17 00:00:00 2001 From: Swell <5782559+sultan@users.noreply.github.com> Date: Sat, 15 Oct 2022 16:04:02 +0200 Subject: [PATCH] Caching update information in reports to increase performance --- .../verify.bsh | 6 +- .../verify.bsh | 8 +-- .../it-plugin-updates-report-001/verify.bsh | 6 +- .../it-plugin-updates-report-002/verify.bsh | 2 +- .../it-plugin-updates-report-003/verify.bsh | 2 +- .../versions/api/ArtifactVersionsCache.java | 2 +- .../AbstractVersionsReportRenderer.java | 59 ++++++++++++----- .../DependencyUpdatesReportRenderer.java | 8 +-- .../PluginUpdatesReportRenderer.java | 64 ++++++++++--------- .../PropertyUpdatesReportRenderer.java | 51 +++++++-------- .../reporting/VersionsReportRendererBase.java | 51 --------------- .../xml/DependencyUpdatesXmlRenderer.java | 8 +-- .../dependency-updates-report.properties | 5 -- .../parent-updates-report.properties | 4 -- .../plugin-updates-report.properties | 5 -- .../property-updates-report.properties | 5 -- 16 files changed, 124 insertions(+), 162 deletions(-) diff --git a/src/it/it-dependency-updates-report-001/verify.bsh b/src/it/it-dependency-updates-report-001/verify.bsh index 289ca69b24..0298f0d67d 100644 --- a/src/it/it-dependency-updates-report-001/verify.bsh +++ b/src/it/it-dependency-updates-report-001/verify.bsh @@ -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 +"\"" ); @@ -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 +"\"" ); @@ -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 +"\"" ); diff --git a/src/it/it-dependency-updates-report-002/verify.bsh b/src/it/it-dependency-updates-report-002/verify.bsh index 8422b69484..019b615555 100644 --- a/src/it/it-dependency-updates-report-002/verify.bsh +++ b/src/it/it-dependency-updates-report-002/verify.bsh @@ -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 +"\"" ); @@ -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 +"\"" ); @@ -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 +"\"" ); diff --git a/src/it/it-plugin-updates-report-001/verify.bsh b/src/it/it-plugin-updates-report-001/verify.bsh index 003f5155ce..d1caa0219f 100644 --- a/src/it/it-plugin-updates-report-001/verify.bsh +++ b/src/it/it-plugin-updates-report-001/verify.bsh @@ -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 +"\"" ); diff --git a/src/it/it-plugin-updates-report-002/verify.bsh b/src/it/it-plugin-updates-report-002/verify.bsh index ee113ae500..299dc4ca1e 100644 --- a/src/it/it-plugin-updates-report-002/verify.bsh +++ b/src/it/it-plugin-updates-report-002/verify.bsh @@ -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 +"\"" ); diff --git a/src/it/it-plugin-updates-report-003/verify.bsh b/src/it/it-plugin-updates-report-003/verify.bsh index ee113ae500..299dc4ca1e 100644 --- a/src/it/it-plugin-updates-report-003/verify.bsh +++ b/src/it/it-plugin-updates-report-003/verify.bsh @@ -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 +"\"" ); diff --git a/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java b/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java index 009070bcd3..e5aa2e384b 100644 --- a/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java +++ b/src/main/java/org/codehaus/mojo/versions/api/ArtifactVersionsCache.java @@ -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 { diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java index c3f9102038..8966d63a6a 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java @@ -58,8 +58,8 @@ public abstract class AbstractVersionsReportRenderer<T> extends VersionsReportRe */ protected T model; - protected ArtifactVersionsCache oldestUpdateCache - = new ArtifactVersionsCache( AbstractVersionDetails::getOldestUpdate ); + protected ArtifactVersionsCache newestUpdateCache + = new ArtifactVersionsCache( AbstractVersionDetails::getNewestUpdate ); protected ArtifactVersionsCache allUpdatesCache = new ArtifactVersionsCache( AbstractVersionDetails::getAllUpdates ); @@ -237,12 +237,12 @@ protected void renderSummaryTableHeader( boolean hasScope, boolean hasType ) "report.latestIncremental", "report.latestMinor", "report.latestMajor" ); } - protected void renderSummaryTableRow( Dependency artifact, ArtifactVersions artifactVersions, - boolean includeScope ) + protected void renderSummaryTableRow( Dependency artifact, ArtifactVersions details, + boolean includeScope ) { sink.tableRow(); sink.tableCell(); - ArtifactVersion[] allUpdates = artifactVersions.getAllUpdates( empty() ); + ArtifactVersion[] allUpdates = allUpdatesCache.get( details, empty() ); if ( allUpdates == null || allUpdates.length == 0 ) { renderSuccessIcon(); @@ -275,37 +275,37 @@ protected void renderSummaryTableRow( Dependency artifact, ArtifactVersions arti sink.tableCell_(); sink.tableCell(); - if ( artifactVersions.getNewestUpdate( of( SUBINCREMENTAL ) ) != null ) + if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) { safeBold(); - sink.text( artifactVersions.getNewestUpdate( of( SUBINCREMENTAL ) ).toString() ); + sink.text( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( artifactVersions.getNewestUpdate( of( INCREMENTAL ) ) != null ) + if ( newestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) { safeBold(); - sink.text( artifactVersions.getNewestUpdate( of( INCREMENTAL ) ).toString() ); + sink.text( newestUpdateCache.get( details, of( INCREMENTAL ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( artifactVersions.getNewestUpdate( of( MINOR ) ) != null ) + if ( newestUpdateCache.get( details, of( MINOR ) ) != null ) { safeBold(); - sink.text( artifactVersions.getNewestUpdate( of( MINOR ) ).toString() ); + sink.text( newestUpdateCache.get( details, of( MINOR ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( artifactVersions.getNewestUpdate( of( MAJOR ) ) != null ) + if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) { safeBold(); - sink.text( artifactVersions.getNewestUpdate( of( MAJOR ) ).toString() ); + sink.text( newestUpdateCache.get( details, of( MAJOR ) ).toString() ); safeBold_(); } sink.tableCell_(); @@ -328,25 +328,25 @@ protected void renderDependencyDetailTable( Dependency artifact, ArtifactVersion sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); ArtifactVersion[] versions = allUpdatesCache.get( details, empty() ); - if ( oldestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) + if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.otherUpdatesAvailable" ) ); } - else if ( oldestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) + else if ( newestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.incrementalUpdatesAvailable" ) ); } - else if ( oldestUpdateCache.get( details, of( MINOR ) ) != null ) + else if ( newestUpdateCache.get( details, of( MINOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.minorUpdatesAvailable" ) ); } - else if ( oldestUpdateCache.get( details, of( MAJOR ) ) != null ) + else if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); @@ -462,4 +462,29 @@ protected void renderTableHeaderCells( String... keys ) sink.tableHeaderCell_(); } ); } + + protected String getLabel( ArtifactVersion version, AbstractVersionDetails details ) + { + if ( equals( version, newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) ) ) + { + return getText( "report.latestSubIncremental" ); + } + + if ( equals( version, newestUpdateCache.get( details, of( INCREMENTAL ) ) ) ) + { + return getText( "report.latestIncremental" ); + } + + if ( equals( version, newestUpdateCache.get( details, of( MINOR ) ) ) ) + { + return getText( "report.latestMinor" ); + } + + if ( equals( version, newestUpdateCache.get( details, of( MAJOR ) ) ) ) + { + return getText( "report.latestMajor" ); + } + + return null; + } } diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java index 8c1f3d42ec..d9c1d013ce 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java @@ -95,19 +95,19 @@ protected OverviewStats computeOverviewStats() OverviewStats stats = new OverviewStats(); model.getAllUpdates().values().forEach( details -> { - if ( oldestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) + if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) { stats.incrementAny(); } - else if ( oldestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) + else if ( newestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) { stats.incrementIncremental(); } - else if ( oldestUpdateCache.get( details, of( MINOR ) ) != null ) + else if ( newestUpdateCache.get( details, of( MINOR ) ) != null ) { stats.incrementMinor(); } - else if ( oldestUpdateCache.get( details, of( MAJOR ) ) != null ) + else if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) { stats.incrementMajor(); } diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java index 1df2288bed..a52d35bb4c 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java @@ -154,19 +154,19 @@ protected PluginOverviewStats computeOverviewStats() PluginOverviewStats stats = new PluginOverviewStats(); model.getAllUpdates().values().forEach( details -> { - if ( oldestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) + if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) { stats.incrementAny(); } - else if ( oldestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) + else if ( newestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) { stats.incrementIncremental(); } - else if ( oldestUpdateCache.get( details, of( MINOR ) ) != null ) + else if ( newestUpdateCache.get( details, of( MINOR ) ) != null ) { stats.incrementMinor(); } - else if ( oldestUpdateCache.get( details, of( MAJOR ) ) != null ) + else if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) { stats.incrementMajor(); } @@ -285,42 +285,64 @@ protected void renderSummaryTableRow( Dependency artifact, PluginUpdatesDetails @SuppressWarnings( "checkstyle:MethodLength" ) private void renderPluginDetail( Dependency artifact, PluginUpdatesDetails plugin ) { - final SinkEventAttributes headerAttributes = new SinkEventAttributeSet(); - headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "20%" ); - final SinkEventAttributes cellAttributes = new SinkEventAttributeSet(); - headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "80%" ); sink.section2(); sink.sectionTitle2(); sink.text( MessageFormat.format( getText( "report.plugin" ), ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() ) ) ); sink.sectionTitle2_(); + + renderPluginDetailTable( plugin ); + + if ( !plugin.getDependencyVersions().isEmpty() ) + { + sink.section3(); + sink.sectionTitle3(); + sink.text( MessageFormat.format( getText( "report.pluginDependencies" ), + ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() ) ) ); + sink.sectionTitle3_(); + + renderSummaryTable( plugin.getDependencyVersions(), false ); + + sink.section3_(); + + plugin.getDependencyVersions().forEach( this::renderDependencyDetail ); + } + sink.section2_(); + } + + private void renderPluginDetailTable( PluginUpdatesDetails plugin ) + { + final SinkEventAttributes headerAttributes = new SinkEventAttributeSet(); + headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "20%" ); + final SinkEventAttributes cellAttributes = new SinkEventAttributeSet(); + headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "80%" ); sink.table(); - sink.tableRows( new int[] {Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT}, false ); + sink.tableRows( new int[] { Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT }, false ); sink.tableRow(); sink.tableHeaderCell( headerAttributes ); sink.text( getText( "report.status" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); ArtifactVersion[] versions = plugin.getAllUpdates( empty() ); - if ( plugin.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) + if ( plugin.getNewestUpdate( of( SUBINCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.otherUpdatesAvailable" ) ); } - else if ( plugin.getOldestUpdate( of( INCREMENTAL ) ) != null ) + else if ( plugin.getNewestUpdate( of( INCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.incrementalUpdatesAvailable" ) ); } - else if ( plugin.getOldestUpdate( of( MINOR ) ) != null ) + else if ( plugin.getNewestUpdate( of( MINOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.minorUpdatesAvailable" ) ); } - else if ( plugin.getOldestUpdate( of( MAJOR ) ) != null ) + else if ( plugin.getNewestUpdate( of( MAJOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); @@ -391,22 +413,6 @@ else if ( plugin.getOldestUpdate( of( MAJOR ) ) != null ) } sink.tableRows_(); sink.table_(); - - if ( !plugin.getDependencyVersions().isEmpty() ) - { - sink.section3(); - sink.sectionTitle3(); - sink.text( MessageFormat.format( getText( "report.pluginDependencies" ), - ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() ) ) ); - sink.sectionTitle3_(); - - renderSummaryTable( plugin.getDependencyVersions(), false ); - - sink.section3_(); - - plugin.getDependencyVersions().forEach( this::renderDependencyDetail ); - } - sink.section2_(); } } diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java index fe5f2de286..677a8c341e 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java @@ -114,11 +114,12 @@ protected void renderSummaryTable( Map<Property, PropertyVersions> contents ) sink.table_(); } - private void renderPropertySummaryTableRow( Property property, PropertyVersions versions ) + private void renderPropertySummaryTableRow( Property property, PropertyVersions details ) { sink.tableRow(); sink.tableCell(); - if ( versions.getAllUpdates( empty() ).length == 0 ) + ArtifactVersion[] allUpdates = allUpdatesCache.get( details, empty() ); + if ( allUpdates.length == 0 ) { renderSuccessIcon(); } @@ -131,41 +132,41 @@ private void renderPropertySummaryTableRow( Property property, PropertyVersions sink.text( "${" + property.getName() + "}" ); sink.tableCell_(); sink.tableCell(); - sink.text( versions.getCurrentVersion().toString() ); + sink.text( details.getCurrentVersion().toString() ); sink.tableCell_(); sink.tableCell(); - if ( versions.getNewestUpdate( of( SUBINCREMENTAL ) ) != null ) + if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) { safeBold(); - sink.text( versions.getNewestUpdate( of( SUBINCREMENTAL ) ).toString() ); + sink.text( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( versions.getNewestUpdate( of( INCREMENTAL ) ) != null ) + if ( newestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) { safeBold(); - sink.text( versions.getNewestUpdate( of( INCREMENTAL ) ).toString() ); + sink.text( newestUpdateCache.get( details, of( INCREMENTAL ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( versions.getNewestUpdate( of( MINOR ) ) != null ) + if ( newestUpdateCache.get( details, of( MINOR ) ) != null ) { safeBold(); - sink.text( versions.getNewestUpdate( of( MINOR ) ).toString() ); + sink.text( newestUpdateCache.get( details, of( MINOR ) ).toString() ); safeBold_(); } sink.tableCell_(); sink.tableCell(); - if ( versions.getNewestUpdate( of( MAJOR ) ) != null ) + if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) { safeBold(); - sink.text( versions.getNewestUpdate( of( MAJOR ) ).toString() ); + sink.text( newestUpdateCache.get( details, of( MAJOR ) ).toString() ); safeBold_(); } sink.tableCell_(); @@ -174,7 +175,7 @@ private void renderPropertySummaryTableRow( Property property, PropertyVersions } @SuppressWarnings( "checkstyle:MethodLength" ) - protected void renderPropertyDetailTable( Property property, PropertyVersions versions ) + protected void renderPropertyDetailTable( Property property, PropertyVersions details ) { final SinkEventAttributes headerAttributes = new SinkEventAttributeSet(); headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "20%" ); @@ -187,27 +188,27 @@ protected void renderPropertyDetailTable( Property property, PropertyVersions ve sink.text( getText( "report.status" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - ArtifactVersion[] artifactVersions = versions.getAllUpdates( empty() ); - Set<String> rangeVersions = getVersionsInRange( property, versions, artifactVersions ); - if ( versions.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) + ArtifactVersion[] artifactVersions = allUpdatesCache.get( details, empty() ); + Set<String> rangeVersions = getVersionsInRange( property, details, artifactVersions ); + if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.otherUpdatesAvailable" ) ); } - else if ( versions.getOldestUpdate( of( INCREMENTAL ) ) != null ) + else if ( newestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.incrementalUpdatesAvailable" ) ); } - else if ( versions.getOldestUpdate( of( MINOR ) ) != null ) + else if ( newestUpdateCache.get( details, of( MINOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.minorUpdatesAvailable" ) ); } - else if ( versions.getOldestUpdate( of( MAJOR ) ) != null ) + else if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); @@ -235,7 +236,7 @@ else if ( versions.getOldestUpdate( of( MAJOR ) ) != null ) sink.text( getText( "report.associations" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - ArtifactAssociation[] associations = versions.getAssociations(); + ArtifactAssociation[] associations = details.getAssociations(); for ( int i = 0; i < associations.length; i++ ) { if ( i > 0 ) @@ -252,7 +253,7 @@ else if ( versions.getOldestUpdate( of( MAJOR ) ) != null ) sink.text( getText( "report.currentVersion" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - sink.text( versions.getCurrentVersion().toString() ); + sink.text( details.getCurrentVersion().toString() ); sink.tableCell_(); sink.tableRow_(); if ( artifactVersions.length > 0 ) @@ -270,7 +271,7 @@ else if ( versions.getOldestUpdate( of( MAJOR ) ) != null ) sink.lineBreak(); } boolean allowed = ( rangeVersions.contains( artifactVersions[i].toString() ) ); - String label = getLabel( artifactVersions[i], versions ); + String label = getLabel( artifactVersions[i], details ); if ( !allowed ) { sink.text( "* " ); @@ -394,19 +395,19 @@ protected OverviewStats computeOverviewStats() OverviewStats stats = new OverviewStats(); model.getAllUpdates().values().forEach( details -> { - if ( oldestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) + if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null ) { stats.incrementAny(); } - else if ( oldestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) + else if ( newestUpdateCache.get( details, of( INCREMENTAL ) ) != null ) { stats.incrementIncremental(); } - else if ( oldestUpdateCache.get( details, of( MINOR ) ) != null ) + else if ( newestUpdateCache.get( details, of( MINOR ) ) != null ) { stats.incrementMinor(); } - else if ( oldestUpdateCache.get( details, of( MAJOR ) ) != null ) + else if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) { stats.incrementMajor(); } diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java b/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java index 28640a78f8..589cfa8a80 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java @@ -25,15 +25,8 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.reporting.AbstractMavenReportRenderer; -import org.codehaus.mojo.versions.api.AbstractVersionDetails; import org.codehaus.plexus.i18n.I18N; -import static java.util.Optional.of; -import static org.codehaus.mojo.versions.api.Segment.INCREMENTAL; -import static org.codehaus.mojo.versions.api.Segment.MAJOR; -import static org.codehaus.mojo.versions.api.Segment.MINOR; -import static org.codehaus.mojo.versions.api.Segment.SUBINCREMENTAL; - /** * Base class over AbstractVersionsReportRenderer providing base * utility methods @@ -149,48 +142,4 @@ protected void safeItalic_() } } - protected String getLabel( ArtifactVersion version, AbstractVersionDetails versions ) - { - if ( equals( version, versions.getNewestUpdate( of( SUBINCREMENTAL ) ) ) ) - { - return getText( "report.latestSubIncremental" ); - } - - if ( equals( version, versions.getOldestUpdate( of( SUBINCREMENTAL ) ) ) ) - { - return getText( "report.nextVersion" ); - } - - if ( equals( version, versions.getOldestUpdate( of( INCREMENTAL ) ) ) ) - { - return getText( "report.nextIncremental" ); - } - - if ( equals( version, versions.getNewestUpdate( of( INCREMENTAL ) ) ) ) - { - return getText( "report.latestIncremental" ); - } - - if ( equals( version, versions.getOldestUpdate( of( MINOR ) ) ) ) - { - return getText( "report.nextMinor" ); - } - - if ( equals( version, versions.getNewestUpdate( of( MINOR ) ) ) ) - { - return getText( "report.latestMinor" ); - } - - if ( equals( version, versions.getOldestUpdate( of( MAJOR ) ) ) ) - { - return getText( "report.nextMajor" ); - } - - if ( equals( version, versions.getNewestUpdate( of( MAJOR ) ) ) ) - { - return getText( "report.latestMajor" ); - } - - return ""; - } } diff --git a/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlRenderer.java b/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlRenderer.java index 6b890c7b52..93bd50541b 100644 --- a/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlRenderer.java @@ -152,19 +152,19 @@ public static String getSummaryBlock( Collection<? extends ArtifactVersions> all int numCur = 0; for ( ArtifactVersions details : allUpdates ) { - if ( details.getOldestUpdate( of( SUBINCREMENTAL ) ) != null ) + if ( details.getNewestUpdate( of( SUBINCREMENTAL ) ) != null ) { numAny++; } - else if ( details.getOldestUpdate( of( INCREMENTAL ) ) != null ) + else if ( details.getNewestUpdate( of( INCREMENTAL ) ) != null ) { numInc++; } - else if ( details.getOldestUpdate( of( MINOR ) ) != null ) + else if ( details.getNewestUpdate( of( MINOR ) ) != null ) { numMin++; } - else if ( details.getOldestUpdate( of( MAJOR ) ) != null ) + else if ( details.getNewestUpdate( of( MAJOR ) ) != null ) { numMaj++; } diff --git a/src/main/resources/dependency-updates-report.properties b/src/main/resources/dependency-updates-report.properties index 1c5eb9722d..9b8626d4a1 100644 --- a/src/main/resources/dependency-updates-report.properties +++ b/src/main/resources/dependency-updates-report.properties @@ -40,14 +40,9 @@ report.currentVersion=Current Version report.scope=Scope report.classifier=Classifier report.type=Type -report.newerVersion=Newer Version(s) -report.nextVersion=Next Version report.latestSubIncremental=Latest Subincremental -report.nextIncremental=Next Incremental report.latestIncremental=Latest Incremental -report.nextMinor=Next Minor report.latestMinor=Latest Minor -report.nextMajor=Next Major report.latestMajor=Latest Major report.updateVersions=Newer versions report.noUpdatesAvailable=No newer versions available. diff --git a/src/main/resources/parent-updates-report.properties b/src/main/resources/parent-updates-report.properties index 2ddf8b1650..9b900def42 100644 --- a/src/main/resources/parent-updates-report.properties +++ b/src/main/resources/parent-updates-report.properties @@ -39,13 +39,9 @@ report.currentVersion=Current Version report.scope=Scope report.classifier=Classifier report.type=Type -report.nextVersion=Next Version report.latestSubIncremental=Latest Subincremental -report.nextIncremental=Next Incremental report.latestIncremental=Latest Incremental -report.nextMinor=Next Minor report.latestMinor=Latest Minor -report.nextMajor=Next Major report.latestMajor=Latest Major report.updateVersions=Newer versions report.noUpdatesAvailable=No newer versions available. diff --git a/src/main/resources/plugin-updates-report.properties b/src/main/resources/plugin-updates-report.properties index c3a37ddc7c..deb1929afe 100644 --- a/src/main/resources/plugin-updates-report.properties +++ b/src/main/resources/plugin-updates-report.properties @@ -42,14 +42,9 @@ report.currentVersion=Current Version report.scope=Scope report.classifier=Classifier report.type=Type -report.newerVersion=Newer Version(s) -report.nextVersion=Next Version report.latestSubIncremental=Latest Subincremental -report.nextIncremental=Next Incremental report.latestIncremental=Latest Incremental -report.nextMinor=Next Minor report.latestMinor=Latest Minor -report.nextMajor=Next Major report.latestMajor=Latest Major report.dependencyStatus=Dependency status report.updateVersions=Newer versions diff --git a/src/main/resources/property-updates-report.properties b/src/main/resources/property-updates-report.properties index ed59150ed7..e0fe103cfb 100644 --- a/src/main/resources/property-updates-report.properties +++ b/src/main/resources/property-updates-report.properties @@ -37,14 +37,9 @@ report.detail.text= report.status=Status report.property=Property report.currentVersion=Current Version -report.newerVersion=Newer Version(s) -report.nextVersion=Next Version report.latestSubIncremental=Latest Subincremental -report.nextIncremental=Next Incremental report.latestIncremental=Latest Incremental -report.nextMinor=Next Minor report.latestMinor=Latest Minor -report.nextMajor=Next Major report.latestMajor=Latest Major report.updateVersions=Newer versions report.noUpdatesAvailable=No newer versions available.