From a10f0b11e89fd65d61938186ddf16fb86ded239e Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Mon, 8 Aug 2022 21:52:41 +0200 Subject: [PATCH] [MJAVADOC-723] Upgrade Maven Reporting API to 3.1.1/Complete with Maven Reporting Impl 3.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This not only upgrades to Maven Reporting API 3.1.1, but also logically completes this plugin with bits from Maven Reporting Impl 3.2.0 because we cannot inherit from AbstractMavenReport since Java does not support multiple inheritance. It should now behave as if using m-r-impl. Co-authored-by: Piotrek Żygieło This closes #158 --- pom.xml | 4 +-- .../maven/plugins/javadoc/JavadocReport.java | 36 +++++++++++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index cc763f61c..8fb6bbc32 100644 --- a/pom.xml +++ b/pom.xml @@ -75,7 +75,7 @@ under the License. 1.1.0 9.4.43.v20210629 - 3.11.0 + 3.12.1 3.2.2 2022-04-17T07:43:18Z 1.7.32 @@ -207,7 +207,7 @@ under the License. org.apache.maven.reporting maven-reporting-api - 3.1.0 + 3.1.1 org.apache.maven diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocReport.java b/src/main/java/org/apache/maven/plugins/javadoc/JavadocReport.java index 7be50290e..4ba2f67c4 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocReport.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocReport.java @@ -28,6 +28,7 @@ import java.util.stream.Collectors; import org.apache.maven.doxia.sink.Sink; +import org.apache.maven.doxia.sink.SinkFactory; import org.apache.maven.doxia.siterenderer.RenderingContext; import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink; import org.apache.maven.plugin.MojoExecutionException; @@ -37,7 +38,7 @@ 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.reporting.MavenReport; +import org.apache.maven.reporting.MavenMultiPageReport; import org.apache.maven.reporting.MavenReportException; import org.codehaus.plexus.util.StringUtils; @@ -55,7 +56,7 @@ @Execute( phase = LifecyclePhase.GENERATE_SOURCES ) public class JavadocReport extends AbstractJavadocMojo - implements MavenReport + implements MavenMultiPageReport { // ---------------------------------------------------------------------- // Report Mojo Parameters @@ -125,8 +126,22 @@ public String getDescription( Locale locale ) /** {@inheritDoc} */ @Override + public void generate( org.codehaus.doxia.sink.Sink sink, Locale locale ) + throws MavenReportException + { + generate( sink, null, locale ); + } + public void generate( Sink sink, Locale locale ) throws MavenReportException + { + generate( sink, null, locale ); + } + + /** {@inheritDoc} */ + @Override + public void generate( Sink sink, SinkFactory sinkFactory, Locale locale ) + throws MavenReportException { outputDirectory = getReportOutputDirectory(); @@ -316,12 +331,21 @@ public void doExecute() return; } + File outputDirectory = new File( getOutputDirectory() ); + + String filename = getOutputName() + ".html"; + + Locale locale = Locale.getDefault(); + try { - RenderingContext context = new RenderingContext( outputDirectory, getOutputName() + ".html" ); - SiteRendererSink sink = new SiteRendererSink( context ); - Locale locale = Locale.getDefault(); - generate( sink, locale ); + // TODO Replace null with real value + RenderingContext docRenderingContext = new RenderingContext( outputDirectory, filename, null ); + + SiteRendererSink sink = new SiteRendererSink( docRenderingContext ); + + generate( sink, null, locale ); + } catch ( MavenReportException | RuntimeException e ) {