slachiewicz opened a new pull request, #243: URL: https://github.com/apache/maven-reporting-impl/pull/243
Fixes the `NoSuchMethodError` reported in apache/maven-project-info-reports-plugin#103, which silently truncates five MPIR reports (`dependency-info`, `ci-management`, `issue-management`, `licenses`, `scm`) while the build still says SUCCESS. ### Why it happens A report plugin never runs against its own Doxia. `DefaultMavenReportExecutor` in maven-reporting-exec imports `org.apache.maven.doxia.sink` (as a prefix, so `.impl` too) from the Maven Site Plugin realm into the report plugin realm, and excludes `doxia-sink-api` from the report plugin's own dependency resolution. Whatever Doxia the site plugin ships is what the report gets. `Sink.verbatim()` with no argument was only added in Doxia 2. Doxia 1 has `verbatim(boolean)`, `verbatim(SinkEventAttributes)` and `verbatim_()`. So as soon as a report plugin picks up maven-reporting-impl 4.x and is rendered by a Maven Site Plugin older than 3.21.0, `verbatimText`/`verbatimLink` blow up. Maven 3.9.x still binds maven-site-plugin 3.12.1 (Doxia 1.11.1) by default, so users hit this without doing anything unusual. ### The change Call `verbatim(SinkEventAttributes)` instead, which exists in both Doxia 1 and Doxia 2. Passing `null` is safe on either: Doxia 1's `Xhtml5BaseSink.verbatim` runs the argument through `SinkUtils.filterAttributes`, which returns `null` for `null` and is then replaced by an empty attribute set. This is the only Doxia 2 only `Sink` method reached on the `generate(Sink, Locale)` path. I checked every `sink.` call in this component against both Doxia branches: `tableRows(int[], boolean)`, `section`, `sectionTitle`, `anchor`, `link`, `text` and `rawText` all exist in Doxia 1 as well. `AbstractMavenReport`'s Doxia 2 only imports (`DocumentRenderingContext`, `SiteModel`, `SiteRendererSink`) are confined to the standalone `execute()` path, where the site plugin realm is not involved. ### Verification Built this branch plus MPIR against it and ran `mvn site` on a small project: - maven-site-plugin 3.12.1 (Doxia 1.11.1): before, `NoSuchMethodError` and truncated reports; after, complete reports with the verbatim blocks rendered. - maven-site-plugin 3.21.0 (Doxia 2.0.0): unchanged, complete reports before and after. The added unit test drives `verbatimText` and `verbatimLink` through a `Sink` proxy that fails on the no argument overload. It fails without the production change. A dynamic proxy is used rather than a `SinkAdapter` subclass because `AbstractSink.verbatim()` is `final` and delegates to the attribute taking overload, which would mask the distinction. ### Not addressed here `verbatimSource` still uses `SinkEventAttributeSet.SOURCE`, which is named `BOXED` in Doxia 1 and would fail the same way with a `NoSuchFieldError`. MPIR does not call it, so it is out of scope for this fix, but it is the other half of MSHARED-1364 and worth a follow up. -- 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]
