Uploaded image for project: 'Maven Site Plugin'
  1. Maven Site Plugin
  2. MSITE-842

$currentFileName and $alignedFileName are incorrect for Maven Report plugins that use several Sink instances

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.8.2
    • doxia integration
    • None

    Description

      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.

      KmReference.java

      Maven Report plugin that use several instances of Sink
       

      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);
                  }
      

      site.vm

      alignedFileName = $alignedFileName
      
      currentFileName = $currentFileName
      
      getDoxiaSourcePath() = $docRenderingContext.getDoxiaSourcePath()
      
      getGenerator() = $docRenderingContext.getGenerator()
      
      getInputName() = $docRenderingContext.getInputName()
      
      getOutputName() = $docRenderingContext.getOutputName()
      
      getParserId() = $docRenderingContext.getParserId()
      
      getRelativePath() = $docRenderingContext.getRelativePath()
      

      Resulting another-page.html

      This file is not km_reference.html, and stil:

      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() = .
      

      Specification

      Modify MultiPageSinkFactory.createSink( File outputDir, String outputName ) so that it creates a new RenderingContext for each sub-sink, with the proper document name.

      Note: MultiPageSinkFactory is a private class in *org.apache.maven.plugins.site.render.ReportDocumentRenderer.java*

      Note: Make sure that the new document name (which will end up in $currentFileName) is calculated relative to the project site output directory, so that sub-sink objects can be in sub-directories.

      Attachments

        Issue Links

          Activity

            People

              michael-o Michael Osipov
              bertrandmartin Bertrand Martin
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m