[ https://issues.apache.org/jira/browse/DOXIASITETOOLS-214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16873020#comment-16873020 ]
Bertrand Martin commented on DOXIASITETOOLS-214: ------------------------------------------------ Thank you [~michael-o]. I've done the research: * The {{$currentFileName}} macro is set with {{RenderingContext.getOutputName()}} in _DefaultSiteRenderer.createDocumentVelocityContext()_ * The _RenderingContext_ object comes from _DocumentContent.getRenderingContext()_ in _DefaultSiteRenderer.createSiteTemplateVelocityContext()_ * _DocumentContent_ object comes from _DefaultSiteRenderer.mergeDocumentIntoSite()_... * ...which is called by _ReportDocumentRenderer.renderDocument()_ in **maven-site-plugin** _ReportDocumentRenderer.renderDocument()_ calls _DefaultSiteRenderer.mergeDocumentIntoSite()_ for the main Sink and also for every sub-sink in a multi-page report. These "sub-sinks" are declared the private class _MultiPageSinkFactory_ with the _MultiPageSinkFactory.createSink()_ method. The problem is that every sub-sink uses the same _RenderingContext_ as the main Sink, with the same result for _getOutputName()_. So the problem is really in **maven-site-plugin** which calls _DefaultSiteRenderer.mergeDocumentIntoSite()_ with a DocumentContent which contains an inaccurate _RenderingContext_. If you agree with this, I'll submit a Pull Request to fix this (with the additional IT and the code fix). > $currentFileName and $alignedFileName are incorrect for Maven Report plugins > that use several Sink instances > ------------------------------------------------------------------------------------------------------------ > > Key: DOXIASITETOOLS-214 > URL: https://issues.apache.org/jira/browse/DOXIASITETOOLS-214 > Project: Maven Doxia Sitetools > Issue Type: Bug > Components: Site renderer > Reporter: Bertrand Martin > Priority: Major > > h1. Problem > The _$currentFileName_ and _$alignedFileName_ macros work just fine for > regular documents (from Markdown source, for example). But for multi-pages > documents, like a Maven Report plugin would generate, these macros keep > returning the name of main page of the report, rather than the page being > rendered. > h2. KmReference.java > Maven Report plugin that use several instances of _Sink_ > > {code:java} > public class KmReference extends AbstractMavenReport { > public String getOutputName() { > return "km-reference"; > } > ... > @Override > protected void executeReport(Locale locale) throws MavenReportException { > ... > // Create a new sink! > Sink kmSink; > try { > kmSink = getSinkFactory().createSink(outputDirectory, > pageFilename); > } catch (IOException e) { > throw new MavenReportException("Could not create sink for " + > pageFilename + " in " + outputDirectory.getAbsolutePath(), e); > } > {code} > h2. site.vm > {code} > alignedFileName = $alignedFileName > currentFileName = $currentFileName > getDoxiaSourcePath() = $docRenderingContext.getDoxiaSourcePath() > getGenerator() = $docRenderingContext.getGenerator() > getInputName() = $docRenderingContext.getInputName() > getOutputName() = $docRenderingContext.getOutputName() > getParserId() = $docRenderingContext.getParserId() > getRelativePath() = $docRenderingContext.getRelativePath() > {code} > h2. Resulting another-page.html > This file is *not* km_reference.html, and stil: > {code} > alignedFileName = km-reference.html > currentFileName = km-reference.html > getDoxiaSourcePath() = $docRenderingContext.getDoxiaSourcePath() > getGenerator() = > com.sentrysoftware.maven:patrolreport-maven-plugin:2.0:km-reference > getInputName() = km-reference.html > getOutputName() = km-reference.html > getParserId() = $docRenderingContext.getParserId() > getRelativePath() = . > {code} > h1. Specification > Modify the _DefaultSiteRenderer.createDocumentVelocityContext()_ method to > expose the actual name of the file being rendered. > Suggestion: > Property name: *renderedFileName* > Property value: {{File( siteContext.getProcessedContentOutput(), > docRenderingContext.getInputName().substring( 0, input.length() - 3 ) )}} -- This message was sent by Atlassian JIRA (v7.6.3#76005)