Keep verbatim blocks working with Doxia 1 - #243
Merged
Conversation
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.
This was referenced Aug 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the
NoSuchMethodErrorreported 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.
DefaultMavenReportExecutorin maven-reporting-exec importsorg.apache.maven.doxia.sink(as a prefix, so.impltoo) from the Maven Site Plugin realm into the report plugin realm, and excludesdoxia-sink-apifrom 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 hasverbatim(boolean),verbatim(SinkEventAttributes)andverbatim_(). 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/verbatimLinkblow 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. Passingnullis safe on either: Doxia 1'sXhtml5BaseSink.verbatimruns the argument throughSinkUtils.filterAttributes, which returnsnullfornulland is then replaced by an empty attribute set.This is the only Doxia 2 only
Sinkmethod reached on thegenerate(Sink, Locale)path. I checked everysink.call in this component against both Doxia branches:tableRows(int[], boolean),section,sectionTitle,anchor,link,textandrawTextall exist in Doxia 1 as well.AbstractMavenReport's Doxia 2 only imports (DocumentRenderingContext,SiteModel,SiteRendererSink) are confined to the standaloneexecute()path, where the site plugin realm is not involved.Verification
Built this branch plus MPIR against it and ran
mvn siteon a small project:NoSuchMethodErrorand truncated reports; after, complete reports with the verbatim blocks rendered.The added unit test drives
verbatimTextandverbatimLinkthrough aSinkproxy that fails on the no argument overload. It fails without the production change. A dynamic proxy is used rather than aSinkAdaptersubclass becauseAbstractSink.verbatim()isfinaland delegates to the attribute taking overload, which would mask the distinction.Not addressed here
verbatimSourcestill usesSinkEventAttributeSet.SOURCE, which is namedBOXEDin Doxia 1 and would fail the same way with aNoSuchFieldError. 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.