Skip to content

Keep verbatim blocks working with Doxia 1 - #243

Merged
slachiewicz merged 1 commit into
apache:masterfrom
slachiewicz:doxia1-compatible-verbatim
Aug 8, 2026
Merged

Keep verbatim blocks working with Doxia 1#243
slachiewicz merged 1 commit into
apache:masterfrom
slachiewicz:doxia1-compatible-verbatim

Conversation

@slachiewicz

Copy link
Copy Markdown
Member

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.

Sink.verbatim() was only added in Doxia 2, but a report plugin never runs
against its own Doxia: DefaultMavenReportExecutor imports the
org.apache.maven.doxia.sink package from the Maven Site Plugin realm into
the report plugin realm and excludes doxia-sink-api from the report
plugin's own dependencies. So with any Maven Site Plugin older than
3.21.0, and that is still the version Maven 3.9.x binds by default, the
call ends in NoSuchMethodError and the report is silently cut short.

Use verbatim(SinkEventAttributes) instead, which exists in Doxia 1 and 2
alike and is null safe in both.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant