Skip to content

Commit

Permalink
[MJAVADOC-723] Upgrade Maven Reporting API to 3.1.1/Complete with Mav…
Browse files Browse the repository at this point in the history
…en Reporting Impl 3.2.0

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 <[email protected]>

This closes #158
  • Loading branch information
michael-o committed Aug 8, 2022
1 parent c19dba2 commit a10f0b1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ under the License.
<plexus-java.version>1.1.0</plexus-java.version>
<jetty.version>9.4.43.v20210629</jetty.version>
<!-- for ITs -->
<sitePluginVersion>3.11.0</sitePluginVersion>
<sitePluginVersion>3.12.1</sitePluginVersion>
<projectInfoReportsPluginVersion>3.2.2</projectInfoReportsPluginVersion>
<project.build.outputTimestamp>2022-04-17T07:43:18Z</project.build.outputTimestamp>
<slf4j.version>1.7.32</slf4j.version>
Expand Down Expand Up @@ -207,7 +207,7 @@ under the License.
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-api</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
36 changes: 30 additions & 6 deletions src/main/java/org/apache/maven/plugins/javadoc/JavadocReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -55,7 +56,7 @@
@Execute( phase = LifecyclePhase.GENERATE_SOURCES )
public class JavadocReport
extends AbstractJavadocMojo
implements MavenReport
implements MavenMultiPageReport
{
// ----------------------------------------------------------------------
// Report Mojo Parameters
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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 )
{
Expand Down

0 comments on commit a10f0b1

Please sign in to comment.