slachiewicz opened a new pull request, #244:
URL: https://github.com/apache/maven-reporting-impl/pull/244
Fixes #217.
`reportToSite()` passed `null` as the `SinkFactory` to `generate(Sink,
SinkFactory, Locale)`, with a TODO saying multipage reports would fail with an
NPE. They do:
```
mvn plugin-report:3.15.1:report
...
Cannot invoke
"org.apache.maven.doxia.sink.SinkFactory.createSink(java.io.File, String)"
because the return value of "PluginReport.getSinkFactory()" is null
at PluginReport.generateMojosDocumentation (PluginReport.java:280)
at AbstractMavenReport.reportToSite (AbstractMavenReport.java:266)
```
Only the site path was affected. `reportToMarkup()`, taken when
`output.format` is set, already builds a sink factory, which is why
`use-as-direct-mojo-markup` exercises the multi-page mojo happily while
`use-as-direct-mojo` could not.
### The change
Hand `generate()` a `MultiPageSinkFactory` mirroring the one in Maven Site
Plugin's `ReportDocumentRenderer`: each `createSink(File, String)` builds a
`DocumentRenderingContext` derived from the main one, wraps it in a
`SiteRendererSink` that remembers where it belongs, and records it. After the
main document is merged into the site, every collected sub-sink is merged the
same way.
Keeping the structure identical to `ReportDocumentRenderer` is deliberate,
so the two stay easy to compare, and so a report behaves the same whether its
goal is invoked directly or through the site.
### Test
The integration test for exactly this was already written and disabled with
a pointer to the issue, in `src/it/use-as-direct-mojo`. This PR enables
`invoker.goals.4 = custom-reporting:multi-page` again and uncomments the
`verify.groovy` assertions, extended to also check the rendered content rather
than mere file existence.
I confirmed it is a real regression guard: reverting only
`AbstractMavenReport` and rerunning the IT reproduces the reported failure.
```
Cannot invoke
"org.apache.maven.doxia.sink.SinkFactory.createSink(java.io.File, String)"
because the return value of "MultiPageReport.getSinkFactory()" is null
Passed: 1, Failed: 1
```
With the change, `mvn verify` is green over the full IT suite (6 passed),
and the multipage goal logs both pages:
```
--- custom-reporting:1.0-SNAPSHOT:multi-page (default-cli) @
use-as-direct-mojo ---
Rendering report to target/reports/multi-page.html
using org.apache.maven.skins:maven-fluido-skin:jar:2.0.0-M9 site
skin
Rendering report to target/reports/multi-second.html
```
I did not rebuild maven-plugin-report-plugin against this branch to
re-verify the original report from the issue; the IT covers the same code path
with the same API.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]