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

Report Verbosity / Concise Reports option 1 - do not merge yet #731

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ public final void setIncludeSnapshots( boolean includeSnapshots )
}
}

public void setVerbose( boolean verbose )
{
synchronized ( currentVersionLock )
{
this.verboseDetail = verbose;
}
}

@Override
public final ArtifactVersion[] getVersions()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ public abstract class AbstractVersionsReport<T>
@Parameter( property = "allowSnapshots", defaultValue = "false" )
protected boolean allowSnapshots;

@Parameter( property = "verboseSummary", defaultValue = "true" )
protected boolean verboseSummary = true;

@Parameter( property = "verboseDetail", defaultValue = "true" )
protected boolean verboseDetail = true;

/**
* Our versions helper.
*/
Expand Down Expand Up @@ -290,6 +296,7 @@ protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange ver
{
final ArtifactVersions artifactVersions =
getHelper().lookupArtifactVersions( artifact, usePluginRepositories );
artifactVersions.setVerbose( verboseDetail );
return artifactVersions.getNewestVersion( versionRange, includeSnapshots );
}
catch ( VersionRetrievalException e )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ && getProject().getOriginalModel().getDependencyManagement().getDependencies() !
{
if ( "html".equals( format ) )
{
rendererFactory.createReportRenderer( getOutputName(), sink, locale, model ).render();
rendererFactory.createReportRenderer( getOutputName(), sink, locale, model,
verboseSummary, verboseDetail ).render();
}
else if ( "xml".equals( format ) )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportEx
.withScope( artifactVersions.getArtifact().getScope() )
.withType( artifactVersions.getArtifact().getType() )
.withClassifier( artifactVersions.getArtifact().getClassifier() )
.build(), artifactVersions ) )
.build(), artifactVersions ), verboseSummary, verboseDetail )
.render();
}
catch ( VersionRetrievalException e )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ protected void doGenerateReport( Locale locale, Sink sink ) throws MavenReportEx
{
if ( "html".equals( format ) )
{
rendererFactory.createReportRenderer( getOutputName(), getSink(), locale, model ).render();
rendererFactory.createReportRenderer( getOutputName(), getSink(), locale, model,
verboseSummary, verboseDetail ).render();
}
else if ( "xml".equals( format ) )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ protected void doGenerateReport( Locale locale, Sink sink )
{
if ( "html".equals( format ) )
{
rendererFactory.createReportRenderer( getOutputName(), getSink(), locale, model ).render();
rendererFactory.createReportRenderer( getOutputName(), getSink(), locale, model,
verboseSummary, verboseDetail ).render();
}
else if ( "xml".equals( format ) )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ public abstract class AbstractVersionsReportRenderer<T> extends VersionsReportRe
protected final SinkEventAttributes headerAttributes
= new SinkEventAttributeSet( SinkEventAttributes.WIDTH, "30%" );

protected boolean verboseSummary = true;

protected boolean verboseDetail = true;

public void setVerboseSummary( boolean verboseSummary )
{
this.verboseSummary = verboseSummary;
}

public void setVerboseDetail( boolean verboseDetail )
{
this.verboseDetail = verboseDetail;
}

protected AbstractVersionsReportRenderer( I18N i18n, Sink sink, Locale locale, String bundleName, T model )
{
super( sink, i18n, locale, bundleName );
Expand Down Expand Up @@ -234,6 +248,10 @@ protected void renderSummaryTableRow( Dependency artifact, ArtifactVersions deta
details.setCurrentVersion( artifact.getVersion() );
ArtifactVersion[] allUpdates = allUpdatesCache.get( details, empty() );
boolean upToDate = allUpdates == null || allUpdates.length == 0;
if ( upToDate && !verboseSummary )
{
return;
}

sink.tableRow();

Expand Down Expand Up @@ -268,6 +286,10 @@ protected void renderDependencyDetailTable( Dependency artifact, ArtifactVersion
{
ArtifactVersion[] allUpdates = allUpdatesCache.get( details, empty() );
boolean upToDate = allUpdates == null || allUpdates.length == 0;
if ( upToDate && !verboseDetail )
{
return;
}

sink.table();
sink.tableRows( new int[] { Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT }, false );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@

import java.util.Locale;
import java.util.Map;
import java.util.Optional;

import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.model.Dependency;
import org.codehaus.mojo.versions.api.ArtifactVersions;
Expand Down Expand Up @@ -91,6 +93,13 @@ protected OverviewStats computeOverviewStats()

protected void renderDependencyDetail( Dependency artifact, ArtifactVersions details )
{
ArtifactVersion[] allUpdates = allUpdatesCache.get( details, Optional.empty() );
boolean upToDate = allUpdates == null || allUpdates.length == 0;
if ( upToDate && !verboseDetail )
{
return;
}

sink.section2();
sink.sectionTitle2();
sink.text( ArtifactUtils.versionlessKey( artifact.getGroupId(), artifact.getArtifactId() ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ protected <T extends OverviewStats> void renderOverviewTableRow( T stats )
protected void renderSummaryTableRow( Dependency artifact, PluginUpdatesDetails details )
{
boolean upToDate = !details.isUpdateAvailable();
if ( upToDate && !verboseSummary )
{
return;
}

sink.tableRow();

Expand Down Expand Up @@ -193,6 +197,10 @@ private void renderPluginDetailTable( PluginUpdatesDetails details )
// warning: using caches here might break plugin report
ArtifactVersion[] allUpdates = details.getAllUpdates( empty() );
boolean upToDate = allUpdates == null || allUpdates.length == 0;
if ( upToDate && !verboseDetail )
{
return;
}

sink.table();
sink.tableRows( new int[] { Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT }, false );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ private void renderPropertySummaryTableRow( Property property, PropertyVersions
{
ArtifactVersion[] allUpdates = allUpdatesCache.get( details, empty() );
boolean upToDate = allUpdates == null || allUpdates.length == 0;
if ( upToDate && !verboseSummary )
{
return;
}

sink.tableRow();

Expand All @@ -123,6 +127,10 @@ protected void renderPropertyDetailTable( Property property, PropertyVersions de
{
ArtifactVersion[] allUpdates = allUpdatesCache.get( details, empty() );
boolean upToDate = allUpdates == null || allUpdates.length == 0;
if ( upToDate && !verboseDetail )
{
return;
}

sink.table();
sink.tableRows( new int[] { Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT }, false );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ public interface ReportRendererFactory
* @param sink sink to use for rendering
* @param locale locale to use for rendering
* @param model data to render
* @param verboseSummary <code>false</code> if up to date rows should be filtered out of report table.
* @param verboseDetail <code>false</code> if up to date rows should be filtered out of report table.
* @return new report renderer
* @throws IllegalArgumentException thrown if the report with the given name could not be found
*/
<T extends ReportRenderer, U> T createReportRenderer( String reportName, Sink sink, Locale locale, U model )
<T extends ReportRenderer, U> T createReportRenderer( String reportName, Sink sink, Locale locale, U model,
boolean verboseSummary, boolean verboseDetail )
throws IllegalArgumentException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,29 +57,37 @@ public ReportRendererFactoryImpl( I18N i18N )
*/
@Override
@SuppressWarnings( "unchecked" )
public <T extends ReportRenderer, U> T createReportRenderer( String reportName, Sink sink, Locale locale, U model )
public <T extends ReportRenderer, U> T createReportRenderer( String reportName, Sink sink, Locale locale, U model,
boolean verboseSummary, boolean verboseDetail )
throws IllegalArgumentException
{
AbstractVersionsReportRenderer renderer = null ;
if ( DEPENDENCY_UPDATES_REPORT.equals( reportName ) )
{
return (T) new DependencyUpdatesReportRenderer<>( i18N, sink, locale, reportName,
renderer = new DependencyUpdatesReportRenderer<>( i18N, sink, locale, reportName,
(DependencyUpdatesModel) model );
}
if ( PLUGIN_UPDATES_REPORT.equals( reportName ) )
{
return (T) new PluginUpdatesReportRenderer( i18N, sink, locale, reportName,
renderer = new PluginUpdatesReportRenderer( i18N, sink, locale, reportName,
(PluginUpdatesModel) model );
}
if ( PROPERTY_UPDATES_REPORT.equals( reportName ) )
{
return (T) new PropertyUpdatesReportRenderer( i18N, sink, locale, reportName,
renderer = new PropertyUpdatesReportRenderer( i18N, sink, locale, reportName,
(PropertyUpdatesModel) model );
}
if ( PARENT_UPDATES_REPORT.equals( reportName ) )
{
return (T) new ParentUpdatesReportRenderer( i18N, sink, locale, reportName,
renderer = new ParentUpdatesReportRenderer( i18N, sink, locale, reportName,
(ParentUpdatesModel) model );
}
if ( renderer != null )
{
renderer.setVerboseSummary( verboseSummary );
renderer.setVerboseDetail( verboseDetail );
return (T) renderer;
}
throw new IllegalArgumentException( "Invalid report name: " + reportName );
}
}