From 299b13b4f3a59617560f8699dfb114ababdaf541 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 9 Nov 2024 17:40:11 +0100 Subject: [PATCH] Upgrade to Doxia 2.x stack fix: #1168 --- pom.xml | 45 +++------- versions-enforcer/pom.xml | 2 +- versions-maven-plugin/pom.xml | 42 ++------- .../verify.groovy | 4 +- .../verify.groovy | 4 +- .../verify.groovy | 4 +- .../verify.groovy | 4 +- .../verify.groovy | 2 +- .../invoker.properties | 2 +- .../verify.groovy | 2 +- .../verify.groovy | 2 +- .../AbstractDependencyUpdatesReportMojo.java | 19 ++--- .../AbstractPluginUpdatesReportMojo.java | 14 ++- .../AbstractPropertyUpdatesReportMojo.java | 17 ++-- .../mojo/versions/AbstractVersionsReport.java | 18 +--- .../versions/DependencyUpdatesReportMojo.java | 1 + .../versions/ParentUpdatesReportMojo.java | 9 +- .../PluginUpdatesAggregateReportMojo.java | 1 + .../versions/PluginUpdatesReportMojo.java | 1 + .../PropertyUpdatesAggregateReportMojo.java | 1 + .../versions/PropertyUpdatesReportMojo.java | 1 + .../mojo/versions/VelocityConfigurator.java | 85 +++++++++++++++++++ .../AbstractVersionsReportRenderer.java | 42 +++------ .../DependencyUpdatesReportRenderer.java | 18 ++-- .../PluginUpdatesReportRenderer.java | 46 +++------- .../PropertyUpdatesReportRenderer.java | 34 +++----- .../reporting/VersionsReportRendererBase.java | 9 +- versions-test/pom.xml | 4 - 28 files changed, 195 insertions(+), 238 deletions(-) create mode 100644 versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/VelocityConfigurator.java diff --git a/pom.xml b/pom.xml index 0993af786d..cb0a4a69a7 100644 --- a/pom.xml +++ b/pom.xml @@ -104,7 +104,7 @@ scm:git:https://github.com/mojohaus/versions.git scm:git:ssh://git@github.com/mojohaus/versions.git - 2.15.0 + HEAD https://github.com/mojohaus/versions/tree/master @@ -120,8 +120,12 @@ 3.6.3 - 1.12.0 - 1.11.1 + + 2.0.0 + 2.0.0 + 4.0.0 + 4.0.0 + 4.11.0 7.1.0 4.2.2 @@ -228,24 +232,18 @@ org.apache.maven.reporting maven-reporting-api - 3.1.1 + ${reportingApiVersion} org.apache.maven.reporting maven-reporting-impl - 3.2.0 + ${reportingImplVersion} org.apache.maven.doxia doxia-core ${doxiaVersion} - - - org.codehaus.plexus - plexus-container-default - - org.apache.maven.doxia @@ -254,26 +252,21 @@ - org.apache.maven.doxia - doxia-site-renderer - ${doxia-sitetoolsVersion} + org.codehaus.plexus + plexus-i18n + 1.0-beta-10 org.codehaus.plexus - plexus-container-default + plexus-component-api + org.apache.maven.doxia doxia-integration-tools ${doxia-sitetoolsVersion} - - - org.codehaus.plexus - plexus-container-default - - @@ -359,11 +352,6 @@ commons-io 2.17.0 - - dom4j - dom4j - 1.6.1 - org.codehaus.plexus plexus-archiver @@ -392,11 +380,6 @@ wagon-provider-api 3.5.3 - - org.apache.maven.doxia - doxia-decoration-model - 1.11.1 - diff --git a/versions-enforcer/pom.xml b/versions-enforcer/pom.xml index 403baa6207..dc87966861 100644 --- a/versions-enforcer/pom.xml +++ b/versions-enforcer/pom.xml @@ -132,7 +132,7 @@ run-its diff --git a/versions-maven-plugin/pom.xml b/versions-maven-plugin/pom.xml index 7484f76d81..a9dd430255 100644 --- a/versions-maven-plugin/pom.xml +++ b/versions-maven-plugin/pom.xml @@ -88,31 +88,18 @@ - org.apache.maven.reporting - maven-reporting-api + org.apache.maven.shared + maven-common-artifact-filters + org.apache.maven.reporting - maven-reporting-impl - - - org.apache.maven - maven-artifact - - - org.apache.maven - maven-core - - - org.apache.maven - maven-plugin-api - - + maven-reporting-api - org.apache.maven.shared - maven-common-artifact-filters + org.apache.maven.reporting + maven-reporting-impl @@ -125,20 +112,9 @@ doxia-sink-api - - org.apache.maven.doxia - doxia-site-renderer - - - org.apache.maven - maven-artifact - - - xml-apis - xml-apis - - + org.codehaus.plexus + plexus-i18n @@ -326,7 +302,7 @@ run-its diff --git a/versions-maven-plugin/src/it/it-823-ranges-update-report-001/verify.groovy b/versions-maven-plugin/src/it/it-823-ranges-update-report-001/verify.groovy index 4c558ea25a..f539c8bfbe 100644 --- a/versions-maven-plugin/src/it/it-823-ranges-update-report-001/verify.groovy +++ b/versions-maven-plugin/src/it/it-823-ranges-update-report-001/verify.groovy @@ -1,5 +1,5 @@ -propertyUpdatesReport = new File( basedir, "target/site/property-updates-report.html" ).text +propertyUpdatesReport = new File( basedir, "target/reports/property-updates-report.html" ).text .replaceAll( '<[^>]+>', ' ' ) .replaceAll( '&[^;]+;', ' ' ) .replaceAll( '\\s+', ' ' ) @@ -12,7 +12,7 @@ assert propertyUpdatesReport =~ / \[1\.1\.2,3\.0\] 1\.1\.3 1\.3 3/ assert propertyUpdatesReport =~ /Newer versions 1\.1\.3 Latest Incremental/ assert propertyUpdatesReport =~ /\b1\.2\.2 1\.3 Latest Minor 2\.0 2\.1 3\.0\b/ -dependencyUpdatesReport = new File( basedir, "target/site/dependency-updates-report.html" ).text +dependencyUpdatesReport = new File( basedir, "target/reports/dependency-updates-report.html" ).text .replaceAll( '<[^>]+>', ' ' ) .replaceAll( '&[^;]+;', ' ' ) .replaceAll( '\\s+', ' ' ) diff --git a/versions-maven-plugin/src/it/it-823-ranges-update-report-002/verify.groovy b/versions-maven-plugin/src/it/it-823-ranges-update-report-002/verify.groovy index c0bf5442e3..5006208a33 100644 --- a/versions-maven-plugin/src/it/it-823-ranges-update-report-002/verify.groovy +++ b/versions-maven-plugin/src/it/it-823-ranges-update-report-002/verify.groovy @@ -1,5 +1,5 @@ -propertyUpdatesReport = new File( basedir, "target/site/property-updates-report.html" ).text +propertyUpdatesReport = new File( basedir, "target/reports/property-updates-report.html" ).text .replaceAll( '<[^>]+>', ' ' ) .replaceAll( '&[^;]+;', ' ' ) .replaceAll( '\\s+', ' ' ) @@ -12,7 +12,7 @@ assert propertyUpdatesReport =~ / \[1\.1\.2,3\.0\) 1\.1\.3 1\.3 3/ assert propertyUpdatesReport =~ /Newer versions 1\.1\.3 Latest Incremental/ assert propertyUpdatesReport =~ /\b1\.2\.2 1\.3 Latest Minor 2\.0 2\.1 \* 3\.0\b/ -dependencyUpdatesReport = new File( basedir, "target/site/dependency-updates-report.html" ).text +dependencyUpdatesReport = new File( basedir, "target/reports/dependency-updates-report.html" ).text .replaceAll( '<[^>]+>', ' ' ) .replaceAll( '&[^;]+;', ' ' ) .replaceAll( '\\s+', ' ' ) diff --git a/versions-maven-plugin/src/it/it-abstract-versions-report-001/verify.groovy b/versions-maven-plugin/src/it/it-abstract-versions-report-001/verify.groovy index c0633c5e32..2b89cf0866 100644 --- a/versions-maven-plugin/src/it/it-abstract-versions-report-001/verify.groovy +++ b/versions-maven-plugin/src/it/it-abstract-versions-report-001/verify.groovy @@ -1,4 +1,4 @@ -dependencyUpdatesReport = new File( basedir, "target/site/dependency-updates-report.html" ).text +dependencyUpdatesReport = new File( basedir, "target/reports/dependency-updates-report.html" ).text .replaceAll( '<[^>]+>', ' ' ) .replaceAll( '&[^;]+;', ' ' ) .replaceAll( '\\s+', ' ' ) @@ -7,7 +7,7 @@ dependencyUpdatesReport = new File( basedir, "target/site/dependency-updates-rep assert dependencyUpdatesReport =~ /\b1\.1\.0-2\b/ // current version of the dependency assert dependencyUpdatesReport =~ /\b3\.0\b/ // latest major available version -pluginUpdatesReport = new File( basedir, "target/site/plugin-updates-report.html" ).text +pluginUpdatesReport = new File( basedir, "target/reports/plugin-updates-report.html" ).text .replaceAll( '<[^>]+>', ' ' ) .replaceAll( '&[^;]+;', ' ' ) .replaceAll( '\\s+', ' ' ) diff --git a/versions-maven-plugin/src/it/it-aggregate-plugn-multiple-versions-same-plugin/verify.groovy b/versions-maven-plugin/src/it/it-aggregate-plugn-multiple-versions-same-plugin/verify.groovy index b47711ca60..ed89a47e93 100644 --- a/versions-maven-plugin/src/it/it-aggregate-plugn-multiple-versions-same-plugin/verify.groovy +++ b/versions-maven-plugin/src/it/it-aggregate-plugn-multiple-versions-same-plugin/verify.groovy @@ -17,10 +17,10 @@ * under the License. */ -def dependenciesUpgradeReport = new File( basedir, 'target/site/dependency-updates-aggregate-report.html') +def dependenciesUpgradeReport = new File( basedir, 'target/reports/dependency-updates-aggregate-report.html') assert dependenciesUpgradeReport.exists() -def pluginsUpgradeReport = new File( basedir, 'target/site/dependency-updates-aggregate-report.html') +def pluginsUpgradeReport = new File( basedir, 'target/reports/dependency-updates-aggregate-report.html') assert pluginsUpgradeReport.exists() \ No newline at end of file diff --git a/versions-maven-plugin/src/it/it-dependency-updates-report-issue-684-001/verify.groovy b/versions-maven-plugin/src/it/it-dependency-updates-report-issue-684-001/verify.groovy index cd8571e77a..e4b1af3042 100644 --- a/versions-maven-plugin/src/it/it-dependency-updates-report-issue-684-001/verify.groovy +++ b/versions-maven-plugin/src/it/it-dependency-updates-report-issue-684-001/verify.groovy @@ -1,2 +1,2 @@ -output = new File( basedir, "target/site/dependency-updates-report.html" ).text +output = new File( basedir, "target/reports/dependency-updates-report.html" ).text assert ! ( output =~ /\b3.0\b/ ) diff --git a/versions-maven-plugin/src/it/it-display-parent-updates-no-updates/invoker.properties b/versions-maven-plugin/src/it/it-display-parent-updates-no-updates/invoker.properties index 20d50bca88..d71819f43b 100644 --- a/versions-maven-plugin/src/it/it-display-parent-updates-no-updates/invoker.properties +++ b/versions-maven-plugin/src/it/it-display-parent-updates-no-updates/invoker.properties @@ -17,5 +17,5 @@ # under the License. # -invoker.goals = ${project.groupId}:${project.artifactId}:2.13.0:display-parent-updates +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:display-parent-updates invoker.mavenOpts = -Dversions.outputFile=./output.txt -DoutputEncoding=UTF-8 diff --git a/versions-maven-plugin/src/it/it-plugin-updates-report-issue-684-001/verify.groovy b/versions-maven-plugin/src/it/it-plugin-updates-report-issue-684-001/verify.groovy index 1d0370e86f..8d54eac58f 100644 --- a/versions-maven-plugin/src/it/it-plugin-updates-report-issue-684-001/verify.groovy +++ b/versions-maven-plugin/src/it/it-plugin-updates-report-issue-684-001/verify.groovy @@ -1,4 +1,4 @@ -output = new File( basedir, 'target/site/plugin-updates-report.html' ).text +output = new File( basedir, 'target/reports/plugin-updates-report.html' ).text .replaceAll( '<[^>]+>', ' ' ) .replaceAll( '&[^;]+;', ' ' ) .replaceAll( '\\s+', ' ' ) diff --git a/versions-maven-plugin/src/it/it-property-updates-report-issue-684-001/verify.groovy b/versions-maven-plugin/src/it/it-property-updates-report-issue-684-001/verify.groovy index 1d0370e86f..8d54eac58f 100644 --- a/versions-maven-plugin/src/it/it-property-updates-report-issue-684-001/verify.groovy +++ b/versions-maven-plugin/src/it/it-property-updates-report-issue-684-001/verify.groovy @@ -1,4 +1,4 @@ -output = new File( basedir, 'target/site/plugin-updates-report.html' ).text +output = new File( basedir, 'target/reports/plugin-updates-report.html' ).text .replaceAll( '<[^>]+>', ' ' ) .replaceAll( '&[^;]+;', ' ' ) .replaceAll( '\\s+', ' ' ) diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractDependencyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractDependencyUpdatesReportMojo.java index a2a359b04a..1986c9ff98 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractDependencyUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractDependencyUpdatesReportMojo.java @@ -103,7 +103,7 @@ public abstract class AbstractDependencyUpdatesReportMojo extends AbstractVersio @Parameter(property = "onlyUpgradable", defaultValue = "false") protected boolean onlyUpgradable; - public AbstractDependencyUpdatesReportMojo( + protected AbstractDependencyUpdatesReportMojo( I18N i18n, ArtifactHandlerManager artifactHandlerManager, RepositorySystem repositorySystem, @@ -115,6 +115,7 @@ public AbstractDependencyUpdatesReportMojo( /** * {@inheritDoc} */ + @Override public boolean isExternalReport() { return false; } @@ -122,6 +123,7 @@ public boolean isExternalReport() { /** * {@inheritDoc} */ + @Override public boolean canGenerateReport() { return true; } @@ -132,7 +134,7 @@ public boolean canGenerateReport() { * @param locale the locale to generate the report for. * @param sink the report formatting tool */ - @SuppressWarnings("deprecation") + @Override protected void doGenerateReport(Locale locale, Sink sink) throws MavenReportException { Set dependencies = getDependencies(); @@ -188,7 +190,7 @@ protected void doGenerateReport(Locale locale, Sink sink) throws MavenReportExce } protected void handleDependencyManagementTransitive( - MavenProject project, Set dependencyManagementCollector) throws MavenReportException { + MavenProject project, Set dependencyManagementCollector) { if (processDependencyManagementTransitive) { if (hasDependencyManagement(project)) { if (getLog().isDebugEnabled()) { @@ -283,7 +285,7 @@ private void renderReport(Locale locale, Sink sink, DependencyUpdatesModel model for (String format : formats) { if ("html".equals(format)) { rendererFactory - .createReportRenderer(getOutputName(), sink, locale, model, allowSnapshots) + .createReportRenderer(getOutputPath(), sink, locale, model, allowSnapshots) .render(); } else if ("xml".equals(format)) { Path outputDir = Paths.get(getProject().getBuild().getDirectory()); @@ -294,7 +296,7 @@ private void renderReport(Locale locale, Sink sink, DependencyUpdatesModel model throw new MavenReportException("Could not create the output directory"); } } - Path outputFile = outputDir.resolve(getOutputName() + ".xml"); + Path outputFile = outputDir.resolve(getOutputPath() + ".xml"); new DependencyUpdatesXmlReportRenderer(model, outputFile, allowSnapshots).render(); } } @@ -322,11 +324,4 @@ protected boolean hasDependencyManagement(MavenProject project) { return project.getDependencyManagement() != null && project.getDependencyManagement().getDependencies() != null; } - - /** - * {@inheritDoc} - */ - public String getOutputName() { - return "dependency-updates-report"; - } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPluginUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPluginUpdatesReportMojo.java index 335576f6cc..b0ce283c82 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPluginUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPluginUpdatesReportMojo.java @@ -75,7 +75,7 @@ public abstract class AbstractPluginUpdatesReportMojo extends AbstractVersionsRe @Parameter(property = "onlyUpgradable", defaultValue = "false") protected boolean onlyUpgradable; - public AbstractPluginUpdatesReportMojo( + protected AbstractPluginUpdatesReportMojo( I18N i18n, ArtifactHandlerManager artifactHandlerManager, RepositorySystem repositorySystem, @@ -87,6 +87,7 @@ public AbstractPluginUpdatesReportMojo( /** * {@inheritDoc} */ + @Override public boolean isExternalReport() { return false; } @@ -94,6 +95,7 @@ public boolean isExternalReport() { /** * {@inheritDoc} */ + @Override public boolean canGenerateReport() { return haveBuildPlugins(getProject()) || haveBuildPluginManagementPlugins(getProject()); } @@ -117,6 +119,7 @@ protected boolean haveBuildPlugins(MavenProject project) { * @param locale the locale to generate the report for. * @param sink the report formatting tool */ + @Override protected void doGenerateReport(Locale locale, Sink sink) throws MavenReportException { Set pluginManagement = getPluginManagement(); @@ -195,7 +198,7 @@ private void renderReport(Locale locale, Sink sink, PluginUpdatesModel model) th for (String format : formats) { if ("html".equals(format)) { rendererFactory - .createReportRenderer(getOutputName(), sink, locale, model, allowSnapshots) + .createReportRenderer(getOutputPath(), sink, locale, model, allowSnapshots) .render(); } else if ("xml".equals(format)) { Path outputDir = Paths.get(getProject().getBuild().getDirectory()); @@ -206,7 +209,7 @@ private void renderReport(Locale locale, Sink sink, PluginUpdatesModel model) th throw new MavenReportException("Could not create the output directory"); } } - Path outputFile = outputDir.resolve(getOutputName() + ".xml"); + Path outputFile = outputDir.resolve(getOutputPath() + ".xml"); new PluginUpdatesXmlReportRenderer(model, outputFile, allowSnapshots).render(); } } @@ -224,9 +227,4 @@ private void handleOnlyProjectPlugins(Set pluginManagement, Set pmPlugin -> plugins.stream().noneMatch(plugin -> PLUGIN_COMPARATOR.compare(plugin, pmPlugin) == 0)); } } - - /** - * {@inheritDoc} - */ - public abstract String getOutputName(); } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPropertyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPropertyUpdatesReportMojo.java index 92e2fa980c..f0e8386fac 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPropertyUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractPropertyUpdatesReportMojo.java @@ -98,7 +98,7 @@ public abstract class AbstractPropertyUpdatesReportMojo extends AbstractVersions @Parameter(property = "propertyUpdatesReportFormats", defaultValue = "html") protected String[] formats = new String[] {"html"}; - public AbstractPropertyUpdatesReportMojo( + protected AbstractPropertyUpdatesReportMojo( I18N i18n, ArtifactHandlerManager artifactHandlerManager, RepositorySystem repositorySystem, @@ -110,6 +110,7 @@ public AbstractPropertyUpdatesReportMojo( /** * {@inheritDoc} */ + @Override public boolean isExternalReport() { return false; } @@ -117,6 +118,7 @@ public boolean isExternalReport() { /** * {@inheritDoc} */ + @Override public boolean canGenerateReport() { return haveBuildProperties(); } @@ -128,7 +130,7 @@ protected boolean haveBuildProperties() { protected void doGenerateReport(Locale locale, Sink sink) throws MavenReportException { try { - final Map updateSet = new TreeMap<>(PROPERTIES_COMPARATOR); + final Map updateSet = new TreeMap<>(PROPERTIES_COMPARATOR); populateUpdateSet(updateSet); renderReport(locale, sink, getPropertyUpdatesModel(updateSet)); @@ -154,7 +156,7 @@ private void renderReport(Locale locale, Sink sink, PropertyUpdatesModel propert for (String format : this.formats) { if ("html".equals(format)) { this.rendererFactory - .createReportRenderer(getOutputName(), sink, locale, propertyUpdatesModel, allowSnapshots) + .createReportRenderer(getOutputPath(), sink, locale, propertyUpdatesModel, allowSnapshots) .render(); } else if ("xml".equals(format)) { Path outputDir = Paths.get(getProject().getBuild().getDirectory()); @@ -165,7 +167,7 @@ private void renderReport(Locale locale, Sink sink, PropertyUpdatesModel propert throw new MavenReportException("Could not create the output directory"); } } - Path outputFile = outputDir.resolve(getOutputName() + ".xml"); + Path outputFile = outputDir.resolve(getOutputPath() + ".xml"); new PropertyUpdatesXmlReportRenderer(propertyUpdatesModel, outputFile, allowSnapshots).render(); } } @@ -185,11 +187,4 @@ protected VersionPropertiesMapRequest getRequest(MavenProject project) { .withAutoLinkItems(this.autoLinkItems) .build(); } - - /** - * {@inheritDoc} - */ - public String getOutputName() { - return "property-updates-report"; - } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java index db398726e2..c2dfebaef1 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/AbstractVersionsReport.java @@ -25,12 +25,9 @@ import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.doxia.sink.Sink; -import org.apache.maven.doxia.siterenderer.Renderer; import org.apache.maven.execution.MavenSession; -import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProject; import org.apache.maven.reporting.AbstractMavenReport; import org.apache.maven.reporting.MavenReportException; import org.apache.maven.wagon.Wagon; @@ -120,9 +117,6 @@ public abstract class AbstractVersionsReport extends AbstractMavenReport { @Parameter(defaultValue = "${session}", required = true, readonly = true) protected MavenSession session; - @Parameter(defaultValue = "${mojoExecution}", required = true, readonly = true) - private MojoExecution mojoExecution; - /** *

Allows specifying the {@linkplain RuleSet} object describing rules * on artifact versions to ignore when considering updates.

@@ -225,16 +219,6 @@ protected void executeReport(Locale locale) throws MavenReportException { protected abstract void doGenerateReport(Locale locale, Sink sink) throws MavenReportException, MojoExecutionException; - @Override - protected MavenProject getProject() { - return project; - } - - @Override - protected Renderer getSiteRenderer() { - return siteRenderer; - } - @Override public String getDescription(Locale locale) { return getText(locale, "report.description"); @@ -253,7 +237,7 @@ public String getName(Locale locale) { * @return the message. */ public String getText(Locale locale, String key) { - return i18n.getString(getOutputName(), locale, key); + return i18n.getString(getOutputPath(), locale, key); } public Boolean getAllowSnapshots() { diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java index f9ee65b277..a894ea83b8 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/DependencyUpdatesReportMojo.java @@ -80,6 +80,7 @@ protected void populateDependencyManagement( /** * {@inheritDoc} */ + @Override public String getOutputName() { return "dependency-updates-report"; } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java index 3e33ff4460..67229c84d4 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/ParentUpdatesReportMojo.java @@ -21,16 +21,13 @@ import javax.inject.Inject; -import java.util.List; import java.util.Locale; import java.util.Map; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; -import org.apache.maven.project.MavenProject; import org.apache.maven.reporting.MavenReportException; import org.apache.maven.wagon.Wagon; import org.codehaus.mojo.versions.api.ArtifactVersions; @@ -49,8 +46,6 @@ */ @Mojo(name = "parent-updates-report", requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true) public class ParentUpdatesReportMojo extends AbstractVersionsReport { - @Parameter(defaultValue = "${reactorProjects}", required = true, readonly = true) - protected List reactorProjects; @Inject protected ParentUpdatesReportMojo( @@ -65,6 +60,7 @@ protected ParentUpdatesReportMojo( /** * {@inheritDoc} */ + @Override public boolean isExternalReport() { return false; } @@ -72,6 +68,7 @@ public boolean isExternalReport() { /** * {@inheritDoc} */ + @Override public boolean canGenerateReport() { if (getProject().getParent() == null) { getLog().warn("Project does not have a parent."); @@ -93,6 +90,7 @@ public boolean canGenerateReport() { * @param sink the report formatting tool */ @SuppressWarnings("deprecation") + @Override protected void doGenerateReport(Locale locale, Sink sink) throws MavenReportException { try { ArtifactVersions artifactVersions = getHelper().lookupArtifactVersions(project.getParentArtifact(), false); @@ -129,6 +127,7 @@ protected void doGenerateReport(Locale locale, Sink sink) throws MavenReportExce /** * {@inheritDoc} */ + @Override public String getOutputName() { return "parent-updates-report"; } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesAggregateReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesAggregateReportMojo.java index 7f814dc504..6b0f5d6dd5 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesAggregateReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesAggregateReportMojo.java @@ -80,6 +80,7 @@ protected void populatePlugins(Set pluginsCollector) { /** * {@inheritDoc} */ + @Override public String getOutputName() { return "plugin-updates-aggregate-report"; } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java index 87fbfc7d82..a72003b088 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PluginUpdatesReportMojo.java @@ -76,6 +76,7 @@ protected void populatePlugins(Set pluginsCollector) { /** * {@inheritDoc} */ + @Override public String getOutputName() { return "plugin-updates-report"; } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesAggregateReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesAggregateReportMojo.java index 61e96b4e64..dd8fca0700 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesAggregateReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesAggregateReportMojo.java @@ -88,6 +88,7 @@ protected boolean haveBuildProperties() { /** * {@inheritDoc} */ + @Override public String getOutputName() { return "property-updates-aggregate-report"; } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java index 6d55e1367a..2cf52c439b 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/PropertyUpdatesReportMojo.java @@ -66,6 +66,7 @@ protected void populateUpdateSet(Map propertyCollect /** * {@inheritDoc} */ + @Override public String getOutputName() { return "property-updates-report"; } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/VelocityConfigurator.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/VelocityConfigurator.java new file mode 100644 index 0000000000..838505fdf9 --- /dev/null +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/VelocityConfigurator.java @@ -0,0 +1,85 @@ +package org.codehaus.mojo.versions; + +/* + * Copyright MojoHaus and Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import javax.inject.Named; +import javax.inject.Singleton; + +import java.util.Properties; + +import org.codehaus.plexus.velocity.VelocityComponentConfigurator; + +/** + * Velocity configurator + */ +/* +Workaround class ... without it, we have an error: + +[WARNING] Error injecting: org.codehaus.mojo.versions.DependencyUpdatesReportMojo +com.google.inject.ProvisionException: Unable to provision, see the following errors: + +1) [Guice/NullInjectedIntoNonNullable]: null returned by binding at LocatorWiring + but the 1st parameter of DefaultVelocityComponent.(DefaultVelocityComponent.java:39) is not @Nullable + at LocatorWiring + at DefaultVelocityComponent.(DefaultVelocityComponent.java:39) + \_ for 1st parameter + at ClassRealm[plugin>org.codehaus.mojo:versions-maven-plugin:2.18.0-SNAPSHOT, parent: ClassLoaders$AppClassLoader@2c854dc5] + \_ installed by: WireModule -> PlexusBindingModule + while locating DefaultVelocityComponent + while locating Object annotated with * + at LocatorWiring + at DefaultSiteRenderer.velocity(DefaultSiteRenderer.java:122) + \_ for field velocity + at ClassRealm[plugin>org.codehaus.mojo:versions-maven-plugin:2.18.0-SNAPSHOT, parent: ClassLoaders$AppClassLoader@2c854dc5] + \_ installed by: WireModule -> PlexusBindingModule + while locating DefaultSiteRenderer + while locating Object annotated with * + while locating DependencyUpdatesReportMojo + +Learn more: + https://github.com/google/guice/wiki/NULL_INJECTED_INTO_NON_NULLABLE + +1 error + +====================== +Full classname legend: +====================== +ClassLoaders$AppClassLoader: "jdk.internal.loader.ClassLoaders$AppClassLoader" +DefaultSiteRenderer: "org.apache.maven.doxia.siterenderer.DefaultSiteRenderer" +DefaultVelocityComponent: "org.codehaus.plexus.velocity.internal.DefaultVelocityComponent" +DependencyUpdatesReportMojo: "org.codehaus.mojo.versions.DependencyUpdatesReportMojo" +LocatorWiring: "org.eclipse.sisu.wire.LocatorWiring" +PlexusBindingModule: "org.eclipse.sisu.plexus.PlexusBindingModule" +WireModule: "org.eclipse.sisu.wire.WireModule" +======================== +End of classname legend: +======================== + +even there is + + public DefaultVelocityComponent(@Nullable VelocityComponentConfigurator componentConfigurator) { + + */ +@Named +@Singleton +class VelocityConfigurator implements VelocityComponentConfigurator { + + @Override + public void configure(Properties properties) { + // nothing to do + } +} diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java index 1b9d99ce8e..9f2c9ae94c 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/AbstractVersionsReportRenderer.java @@ -79,45 +79,33 @@ protected AbstractVersionsReportRenderer( * {@inheritDoc} */ protected void renderBody() { - sink.section1(); - sink.sectionTitle1(); - sink.text(getText("report.overview.title")); - sink.sectionTitle1_(); - sink.paragraph(); - sink.text(getText("report.overview.text")); - sink.paragraph_(); + startSection(getText("report.overview.title")); + paragraph(getText("report.overview.text")); renderOverview(); renderManagementSummaryTable(); renderSummaryTable(); - sink.section1_(); + endSection(); - sink.section1(); - sink.sectionTitle1(); - sink.text(getText("report.detail.title")); - sink.sectionTitle1_(); - sink.paragraph(); - sink.text(getText("report.detail.text")); - sink.paragraph_(); + startSection(getText("report.detail.title")); + paragraph(getText("report.detail.text")); renderDetails(); - sink.section1_(); + endSection(); } /** * Renders the "Overview" table */ protected void renderOverview() { - sink.table(); - sink.tableRows(null, false); + startTable(); sink.tableRow(); renderOverviewTableRow(computeOverviewStats()); sink.tableRow_(); - sink.tableRows_(); - sink.table_(); + endTable(); } /** @@ -188,8 +176,7 @@ protected void renderIcon(boolean success) { protected abstract void renderDetails(); protected void renderSummaryTable(Map contents, boolean hasScope) { - sink.table(); - sink.tableRows(null, false); + startTable(); sink.tableRow(); renderSummaryTableHeader(hasScope, true); @@ -201,8 +188,7 @@ protected void renderSummaryTable(Map contents, bo renderSummaryTableHeader(hasScope, true); sink.tableRow_(); - sink.tableRows_(); - sink.table_(); + endTable(); } protected void renderSummaryTableHeader(boolean hasScope, boolean hasType) { @@ -253,8 +239,7 @@ protected void renderDependencyDetailTable(Dependency artifact, ArtifactVersions ArtifactVersion[] allUpdates = allUpdatesCache.get(details, empty(), isAllowSnapshots()); boolean upToDate = allUpdates == null || allUpdates.length == 0; - sink.table(); - sink.tableRows(new int[] {Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT}, false); + startTable(new int[] {Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT}, false); renderTwoCellsRow("report.status", () -> renderStatus(details)); renderTwoCellsRow("report.groupId", artifact.getGroupId()); @@ -269,8 +254,7 @@ protected void renderDependencyDetailTable(Dependency artifact, ArtifactVersions renderTwoCellsRow("report.updateVersions", () -> renderVersions(allUpdates, details)); } - sink.tableRows_(); - sink.table_(); + endTable(); } /** @@ -347,7 +331,7 @@ private List getArtifactVersionRange(AbstractVersionDetails details } catch (InvalidVersionSpecificationException ignored) { ignored.printStackTrace(System.err); } - return Collections.EMPTY_LIST; + return Collections.emptyList(); } /** diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java index 7233e3371c..983247002a 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/DependencyUpdatesReportRenderer.java @@ -62,19 +62,14 @@ protected void renderManagementSummaryTable() { } protected void renderTable(String titleKey, Map contents, String emptyKey) { - sink.section2(); - sink.sectionTitle2(); - sink.text(getText(titleKey)); - sink.sectionTitle2_(); + startSection(getText(titleKey)); if (contents.isEmpty()) { - sink.paragraph(); - sink.text(getText(emptyKey)); - sink.paragraph_(); + paragraph(getText(emptyKey)); } else { renderSummaryTable(contents, true); } - sink.section2_(); + endSection(); } @Override @@ -83,11 +78,8 @@ protected OverviewStats computeOverviewStats() { } protected void renderDependencyDetail(Dependency artifact, ArtifactVersions details) { - sink.section2(); - sink.sectionTitle2(); - sink.text(ArtifactUtils.versionlessKey(artifact.getGroupId(), artifact.getArtifactId())); - sink.sectionTitle2_(); + startSection(ArtifactUtils.versionlessKey(artifact.getGroupId(), artifact.getArtifactId())); renderDependencyDetailTable(artifact, details, true); - sink.section2_(); + endSection(); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java index 43a2d059fe..16beebc60d 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PluginUpdatesReportRenderer.java @@ -65,35 +65,26 @@ protected void renderDetails() { } private void renderDependencyDetail(Dependency dependency, ArtifactVersions details) { - sink.section3(); - sink.sectionTitle3(); - sink.text(MessageFormat.format( + startSection(MessageFormat.format( getText("report.pluginDependency"), ArtifactUtils.versionlessKey(dependency.getGroupId(), dependency.getArtifactId()))); - sink.sectionTitle3_(); renderDependencyDetailTable(dependency, details, false); - sink.section3_(); + endSection(); } private void renderTable(String titleKey, Map contents, String emptyKey) { - sink.section2(); - sink.sectionTitle2(); - sink.text(getText(titleKey)); - sink.sectionTitle2_(); + startSection(getText(titleKey)); if (contents.isEmpty()) { - sink.paragraph(); - sink.text(getText(emptyKey)); - sink.paragraph_(); + paragraph(getText(emptyKey)); } else { renderSummaryTable(contents); } - sink.section2_(); + endSection(); } protected void renderSummaryTable(Map contents) { - sink.table(); - sink.tableRows(null, false); + startTable(); sink.tableRow(); renderSummaryTableHeader(false, false); @@ -105,8 +96,7 @@ protected void renderSummaryTable(Map contents renderSummaryTableHeader(false, false); sink.tableRow_(); - sink.tableRows_(); - sink.table_(); + endTable(); } /** @@ -153,29 +143,21 @@ protected void renderSummaryTableRow(Dependency artifact, PluginUpdatesDetails d } private void renderPluginDetail(Dependency artifact, PluginUpdatesDetails details) { - sink.section2(); - sink.sectionTitle2(); - sink.text(MessageFormat.format( + startSection(MessageFormat.format( getText("report.plugin"), ArtifactUtils.versionlessKey(details.getGroupId(), details.getArtifactId()))); - sink.sectionTitle2_(); - renderPluginDetailTable(details); if (!details.getDependencyVersions().isEmpty()) { - sink.section3(); - sink.sectionTitle3(); - sink.text(MessageFormat.format( + startSection(MessageFormat.format( getText("report.pluginDependencies"), ArtifactUtils.versionlessKey(details.getGroupId(), details.getArtifactId()))); - sink.sectionTitle3_(); renderSummaryTable(details.getDependencyVersions(), false); - - sink.section3_(); + endSection(); details.getDependencyVersions().forEach(this::renderDependencyDetail); } - sink.section2_(); + endSection(); } private void renderPluginDetailTable(PluginUpdatesDetails details) { @@ -183,8 +165,7 @@ private void renderPluginDetailTable(PluginUpdatesDetails details) { ArtifactVersion[] allUpdates = details.getAllUpdates(empty(), isAllowSnapshots()); boolean upToDate = allUpdates == null || allUpdates.length == 0; - sink.table(); - sink.tableRows(new int[] {Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT}, false); + startTable(new int[] {Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT}, false); renderTwoCellsRow("report.status", () -> renderStatus(details)); renderTwoCellsRow("report.groupId", details.getGroupId()); @@ -194,7 +175,6 @@ private void renderPluginDetailTable(PluginUpdatesDetails details) { renderTwoCellsRow("report.updateVersions", () -> renderVersions(allUpdates, details)); } - sink.tableRows_(); - sink.table_(); + endTable(); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java index 5c7269f5ef..273790a940 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/PropertyUpdatesReportRenderer.java @@ -52,7 +52,7 @@ protected void renderManagementSummaryTable() {} @Override protected void renderSummaryTable() { - renderTable("report.overview.property", model.getAllUpdates(), "report.overview.noProperty"); + renderTable(model.getAllUpdates()); } /** @@ -63,25 +63,19 @@ protected void renderDetails() { model.getAllUpdates().forEach(this::renderPropertyDetail); } - protected void renderTable(String titleKey, Map contents, String emptyKey) { - sink.section2(); - sink.sectionTitle2(); - sink.text(getText(titleKey)); - sink.sectionTitle2_(); + protected void renderTable(Map contents) { + startSection(getText("report.overview.property")); if (contents.isEmpty()) { - sink.paragraph(); - sink.text(getText(emptyKey)); - sink.paragraph_(); + paragraph(getText("report.overview.noProperty")); } else { renderSummaryTable(contents); } - sink.section2_(); + endSection(); } protected void renderSummaryTable(Map contents) { - sink.table(); - sink.tableRows(null, false); + startTable(); sink.tableRow(); renderSummaryTableHeader(false, false); @@ -93,8 +87,7 @@ protected void renderSummaryTable(Map contents) { renderSummaryTableHeader(false, false); sink.tableRow_(); - sink.tableRows_(); - sink.table_(); + endTable(); } private void renderPropertySummaryTableRow(Property property, PropertyVersions details) { @@ -117,8 +110,7 @@ protected void renderPropertyDetailTable(Property property, PropertyVersions det ArtifactVersion[] allUpdates = allUpdatesCache.get(details, empty(), isAllowSnapshots()); boolean upToDate = allUpdates == null || allUpdates.length == 0; - sink.table(); - sink.tableRows(new int[] {Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT}, false); + startTable(new int[] {Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT}, false); renderTwoCellsRow("report.status", () -> renderStatus(details)); renderTwoCellsRow("report.property", "${" + property.getName() + "}"); @@ -133,8 +125,7 @@ protected void renderPropertyDetailTable(Property property, PropertyVersions det renderTwoCellsRow("report.searchReactor", property.isSearchReactor()); renderTwoCellsRow("report.preferReactor", property.isPreferReactor()); - sink.tableRows_(); - sink.table_(); + endTable(); } /** @@ -174,11 +165,8 @@ protected OverviewStats computeOverviewStats() { } private void renderPropertyDetail(Property property, PropertyVersions details) { - sink.section2(); - sink.sectionTitle2(); - sink.text("${" + property.getName() + "}"); - sink.sectionTitle2_(); + startSection("${" + property.getName() + "}"); renderPropertyDetailTable(property, details); - sink.section2_(); + endSection(); } } diff --git a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java index 10fa592e79..b46f2ce204 100644 --- a/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java +++ b/versions-maven-plugin/src/main/java/org/codehaus/mojo/versions/reporting/VersionsReportRendererBase.java @@ -55,7 +55,8 @@ public abstract class VersionsReportRendererBase extends AbstractMavenReportRend */ protected String bundleName; - public VersionsReportRendererBase(Sink sink, I18N i18n, Locale locale, String bundleName, boolean allowSnapshots) { + protected VersionsReportRendererBase( + Sink sink, I18N i18n, Locale locale, String bundleName, boolean allowSnapshots) { super(sink); this.i18n = i18n; this.locale = locale; @@ -102,11 +103,7 @@ protected boolean equals(ArtifactVersion v1, ArtifactVersion v2) { * headers from */ protected void renderTableHeaderCells(String... keys) { - Arrays.stream(keys).map(this::getText).forEachOrdered(str -> { - sink.tableHeaderCell(); - sink.text(str); - sink.tableHeaderCell_(); - }); + Arrays.stream(keys).map(this::getText).forEachOrdered(this::tableHeaderCell); } /** diff --git a/versions-test/pom.xml b/versions-test/pom.xml index 41906af21b..1068fc6958 100644 --- a/versions-test/pom.xml +++ b/versions-test/pom.xml @@ -56,10 +56,6 @@ org.apache.maven.doxia doxia-integration-tools
- - org.apache.maven.doxia - doxia-decoration-model - org.apache.commons commons-text