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 5014ab6647..7fe827e9fd 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java @@ -469,6 +469,7 @@ protected void renderTableHeaderCells( String... keys ) protected String getLabel( ArtifactVersion version, AbstractVersionDetails details ) { + if ( equals( version, newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) ) ) { return getText( "report.latestSubIncremental" ); diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java b/src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java index bde72a9218..998a2b0f52 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/OverviewStats.java @@ -58,7 +58,7 @@ public class OverviewStats * @param updates collection of all version updates, typically from * {@linkplain org.codehaus.mojo.versions.reporting.model.DependencyUpdatesModel#getAllUpdates()} * @param cache if not null, cache to retrieve the version information, initialised with - * the {@link ArtifactVersions#getOldestUpdate(Optional)} update information + * the {@link ArtifactVersions#getNewestUpdate(Optional)} update information * @param subclass of {@linkplain OverviewStats} * @param subclass of {@linkplain ArtifactVersions} * @return instance of the {@linkplain OverviewStats} @@ -69,19 +69,19 @@ public static T fromUpdate OverviewStats stats = new OverviewStats(); updates.forEach( details -> { - if ( getOldestUpdate( cache, details, of( SUBINCREMENTAL ) ) != null ) + if ( getNewestUpdate( cache, details, of( SUBINCREMENTAL ) ) != null ) { stats.incrementAny(); } - else if ( getOldestUpdate( cache, details, of( INCREMENTAL ) ) != null ) + else if ( getNewestUpdate( cache, details, of( INCREMENTAL ) ) != null ) { stats.incrementIncremental(); } - else if ( getOldestUpdate( cache, details, of( MINOR ) ) != null ) + else if ( getNewestUpdate( cache, details, of( MINOR ) ) != null ) { stats.incrementMinor(); } - else if ( getOldestUpdate( cache, details, of( MAJOR ) ) != null ) + else if ( getNewestUpdate( cache, details, of( MAJOR ) ) != null ) { stats.incrementMajor(); } @@ -93,11 +93,11 @@ else if ( getOldestUpdate( cache, details, of( MAJOR ) ) != null ) return (T) stats; } - protected static ArtifactVersion getOldestUpdate( ArtifactVersionsCache cache, + protected static ArtifactVersion getNewestUpdate( ArtifactVersionsCache cache, V details, - Optional segment ) + Optional segment ) { - return cache != null ? cache.get( details, segment ) : details.getOldestUpdate( segment ); + return cache != null ? cache.get( details, segment ) : details.getNewestUpdate( segment ); } public int getMajor() diff --git a/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java b/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java index 5275c17e4f..2d215b75cf 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/PluginOverviewStats.java @@ -55,7 +55,7 @@ public void incrementDependencies() * * @param updates collection of all version updates, typically from {@linkplain PluginUpdatesModel#getAllUpdates()} * @param cache if not null, cache to retrieve the version information, initialised with - * the {@link ArtifactVersions#getOldestUpdate(Optional)} update information + * the {@link ArtifactVersions#getNewestUpdate(Optional)} update information * @param always equal to {@linkplain PluginOverviewStats} * @param always equal to {@linkplain org.codehaus.mojo.versions.PluginUpdatesDetails} * @return instance of the {@linkplain PluginOverviewStats}, initialised with the update information @@ -66,19 +66,19 @@ public static T fromUpdate PluginOverviewStats stats = new PluginOverviewStats(); updates.forEach( details -> { - if ( getOldestUpdate( cache, details, of( SUBINCREMENTAL ) ) != null ) + if ( getNewestUpdate( cache, details, of( SUBINCREMENTAL ) ) != null ) { stats.incrementAny(); } - else if ( getOldestUpdate( cache, details, of( INCREMENTAL ) ) != null ) + else if ( getNewestUpdate( cache, details, of( INCREMENTAL ) ) != null ) { stats.incrementIncremental(); } - else if ( getOldestUpdate( cache, details, of( MINOR ) ) != null ) + else if ( getNewestUpdate( cache, details, of( MINOR ) ) != null ) { stats.incrementMinor(); } - else if ( getOldestUpdate( cache, details, of( MAJOR ) ) != null ) + else if ( getNewestUpdate( cache, 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 f6fdb3d39e..7f38c91d5b 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java @@ -30,9 +30,7 @@ import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet; import org.apache.maven.model.Dependency; import org.codehaus.mojo.versions.PluginUpdatesDetails; -import org.codehaus.mojo.versions.api.AbstractVersionDetails; import org.codehaus.mojo.versions.api.ArtifactVersions; -import org.codehaus.mojo.versions.api.ArtifactVersionsCache; import org.codehaus.mojo.versions.reporting.model.PluginUpdatesModel; import org.codehaus.plexus.i18n.I18N; @@ -48,8 +46,6 @@ */ public class PluginUpdatesReportRenderer extends AbstractVersionsReportRenderer { - protected ArtifactVersionsCache newestUpdateCache - = new ArtifactVersionsCache( AbstractVersionDetails::getNewestUpdate ); public PluginUpdatesReportRenderer( I18N i18n, Sink sink, Locale locale, String bundleName, PluginUpdatesModel model ) @@ -157,9 +153,11 @@ protected void renderOverviewTableRow( T stats ) protected void renderSummaryTableRow( Dependency artifact, PluginUpdatesDetails details ) { + boolean upToDate = !details.isUpdateAvailable(); + sink.tableRow(); sink.tableCell(); - if ( !details.isUpdateAvailable() ) + if ( upToDate ) { renderSuccessIcon(); } @@ -237,39 +235,43 @@ protected void renderSummaryTableRow( Dependency artifact, PluginUpdatesDetails } @SuppressWarnings( "checkstyle:MethodLength" ) - private void renderPluginDetail( Dependency artifact, PluginUpdatesDetails plugin ) + private void renderPluginDetail( Dependency artifact, PluginUpdatesDetails details ) { sink.section2(); sink.sectionTitle2(); sink.text( MessageFormat.format( getText( "report.plugin" ), - ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() ) ) ); + ArtifactUtils.versionlessKey( details.getGroupId(), details.getArtifactId() ) ) ); sink.sectionTitle2_(); - renderPluginDetailTable( plugin ); + renderPluginDetailTable( details ); - if ( !plugin.getDependencyVersions().isEmpty() ) + if ( !details.getDependencyVersions().isEmpty() ) { sink.section3(); sink.sectionTitle3(); sink.text( MessageFormat.format( getText( "report.pluginDependencies" ), - ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() ) ) ); + ArtifactUtils.versionlessKey( details.getGroupId(), details.getArtifactId() ) ) ); sink.sectionTitle3_(); - renderSummaryTable( plugin.getDependencyVersions(), false ); + renderSummaryTable( details.getDependencyVersions(), false ); sink.section3_(); - plugin.getDependencyVersions().forEach( this::renderDependencyDetail ); + details.getDependencyVersions().forEach( this::renderDependencyDetail ); } sink.section2_(); } - private void renderPluginDetailTable( PluginUpdatesDetails plugin ) + private void renderPluginDetailTable( PluginUpdatesDetails details ) { + // warning: using caches here may break plugin report + ArtifactVersion[] allUpdates = details.getAllUpdates( empty() ); + boolean upToDate = allUpdates == null || allUpdates.length == 0; + final SinkEventAttributes headerAttributes = new SinkEventAttributeSet(); - headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "20%" ); + headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "70%" ); final SinkEventAttributes cellAttributes = new SinkEventAttributeSet(); - headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "80%" ); + headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "30%" ); sink.table(); sink.tableRows( new int[] { Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT }, false ); sink.tableRow(); @@ -277,26 +279,25 @@ private void renderPluginDetailTable( PluginUpdatesDetails plugin ) sink.text( getText( "report.status" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - ArtifactVersion[] versions = plugin.getAllUpdates( empty() ); - if ( plugin.getNewestUpdate( of( SUBINCREMENTAL ) ) != null ) + if ( details.getNewestUpdate( of( SUBINCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.otherUpdatesAvailable" ) ); } - else if ( plugin.getNewestUpdate( of( INCREMENTAL ) ) != null ) + else if ( details.getNewestUpdate( of( INCREMENTAL ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.incrementalUpdatesAvailable" ) ); } - else if ( plugin.getNewestUpdate( of( MINOR ) ) != null ) + else if ( details.getNewestUpdate( of( MINOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); sink.text( getText( "report.minorUpdatesAvailable" ) ); } - else if ( plugin.getNewestUpdate( of( MAJOR ) ) != null ) + else if ( details.getNewestUpdate( of( MAJOR ) ) != null ) { renderWarningIcon(); sink.nonBreakingSpace(); @@ -315,7 +316,7 @@ else if ( plugin.getNewestUpdate( of( MAJOR ) ) != null ) sink.text( getText( "report.groupId" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - sink.text( plugin.getGroupId() ); + sink.text( details.getGroupId() ); sink.tableCell_(); sink.tableRow_(); sink.tableRow(); @@ -323,7 +324,7 @@ else if ( plugin.getNewestUpdate( of( MAJOR ) ) != null ) sink.text( getText( "report.artifactId" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - sink.text( plugin.getArtifactId() ); + sink.text( details.getArtifactId() ); sink.tableCell_(); sink.tableRow_(); sink.tableRow(); @@ -331,28 +332,28 @@ else if ( plugin.getNewestUpdate( of( MAJOR ) ) != null ) sink.text( getText( "report.currentVersion" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - sink.text( plugin.getVersion() ); + sink.text( details.getVersion() ); sink.tableCell_(); sink.tableRow_(); - if ( versions != null && versions.length > 0 ) + if ( !upToDate ) { sink.tableRow(); sink.tableHeaderCell( headerAttributes ); sink.text( getText( "report.updateVersions" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - for ( int i = 0; i < versions.length; i++ ) + for ( int i = 0; i < allUpdates.length; i++ ) { if ( i > 0 ) { sink.lineBreak(); } - String label = getLabel( versions[i], plugin ); + String label = getLabel( allUpdates[i], details ); if ( label != null ) { safeBold(); } - sink.text( versions[i].toString() ); + sink.text( allUpdates[i].toString() ); if ( label != null ) { safeBold_(); 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 0cb300d912..ddb7287e82 100644 --- a/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java @@ -261,12 +261,12 @@ else if ( newestUpdateCache.get( details, of( MAJOR ) ) != null ) sink.tableRow_(); if ( !upToDate ) { + Set rangeVersions = getVersionsInRange( property, details, allUpdates ); sink.tableRow(); sink.tableHeaderCell( headerAttributes ); sink.text( getText( "report.updateVersions" ) ); sink.tableHeaderCell_(); sink.tableCell( cellAttributes ); - Set rangeVersions = getVersionsInRange( property, details, allUpdates ); boolean someNotAllowed = false; for ( int i = 0; i < allUpdates.length; i++ ) { diff --git a/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlRenderer.java b/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlRenderer.java deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java b/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java index 25dfb3dcbc..dee099f597 100644 --- a/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java +++ b/src/main/java/org/codehaus/mojo/versions/xml/DependencyUpdatesXmlReportRenderer.java @@ -62,8 +62,8 @@ public class DependencyUpdatesXmlReportRenderer implements ReportRenderer { private final DependencyUpdatesModel model; private final Path outputFile; - private final ArtifactVersionsCache oldestUpdateCache - = new ArtifactVersionsCache( AbstractVersionDetails::getOldestUpdate ); + private final ArtifactVersionsCache newestUpdateCache + = new ArtifactVersionsCache( AbstractVersionDetails::getNewestUpdate ); /** * Creates a new instance * @param model object containing the updates model @@ -89,7 +89,7 @@ public void render() setSummary( new DependencyReportSummary() {{ OverviewStats overviewStats = OverviewStats.fromUpdates( model.getAllUpdates().values(), - oldestUpdateCache ); + newestUpdateCache ); setUsingLastVersion( String.valueOf( overviewStats.getUpToDate() ) ); setNextVersionAvailable( String.valueOf( overviewStats.getAny() ) ); setNextIncrementalAvailable( String.valueOf( overviewStats.getIncremental() ) ); @@ -127,14 +127,14 @@ private static List createDependencyInfo( Map createPluginInfo( MapString - nextVersion + lastVersion String diff --git a/src/main/mdo/plugin-updates-report.mdo b/src/main/mdo/plugin-updates-report.mdo index 25c7fa428c..12934b125f 100644 --- a/src/main/mdo/plugin-updates-report.mdo +++ b/src/main/mdo/plugin-updates-report.mdo @@ -139,7 +139,7 @@ under the License. String - nextVersion + lastVersion String diff --git a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java index 1d8994aa80..bb8d851ae6 100644 --- a/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java +++ b/src/test/java/org/codehaus/mojo/versions/DependencyUpdatesXmlRendererTest.java @@ -95,7 +95,7 @@ public void testReportGeneration() throws IOException assertThat( output, containsString( "0" ) ); assertThat( output, containsString( "1.0.0" ) ); - assertThat( output, containsString( "1.0.1" ) ); + assertThat( output, containsString( "2.0.0" ) ); assertThat( output, containsString( "1.0.1" ) ); assertThat( output, containsString( "1.1.0" ) ); assertThat( output, containsString( "2.0.0" ) ); diff --git a/src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java b/src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java index 5d653ae5e7..f39a880cc9 100644 --- a/src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java +++ b/src/test/java/org/codehaus/mojo/versions/PluginUpdatesXmlRendererTest.java @@ -103,7 +103,7 @@ public void testReportGeneration() throws IOException assertThat( output, containsString( "1" ) ); assertThat( output, containsString( "1.0.0" ) ); - assertThat( output, containsString( "1.0.1" ) ); + assertThat( output, containsString( "2.0.0" ) ); assertThat( output, containsString( "1.0.1" ) ); assertThat( output, containsString( "1.1.0" ) ); assertThat( output, containsString( "2.0.0" ) );