Class ReportScriptingMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo, org.apache.maven.reporting.MavenMultiPageReport, org.apache.maven.reporting.MavenReport

    @Mojo(name="scripted-report")
    @Execute(phase=NONE)
    public class ReportScriptingMojo
    extends org.apache.maven.reporting.AbstractMavenReport
    Maven plugin goal to use JavaScript for configuring MavenReport during the LifecyclePhase.SITE.

    This plugin goal intends to allow the use of JavaScript during SITE lifecycle phase with the help of ReportScript. The motivation behind this is the inability to use Maven AntRun during SITE phase.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      org.codehaus.plexus.configuration.PlexusConfiguration script
      The script to be used to produce the report, in the scripting language identified by its mimetype or engine attribute.
      • Fields inherited from class org.apache.maven.reporting.AbstractMavenReport

        outputDirectory, project, siteRenderer
      • Fields inherited from interface org.apache.maven.reporting.MavenReport

        CATEGORY_PROJECT_INFORMATION, CATEGORY_PROJECT_REPORTS, ROLE
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • Method Summary

      Modifier and Type Method Description
      boolean canGenerateReport()
      Returns true if a report can be generated, false otherwise.
      org.apache.maven.reporting.MavenReportException exceptionWrap​(Object object)
      Wraps the input object in a MavenReportException.
      protected void executeReport​(Locale locale)
      String getCategoryName()
      Returns the category name of this report, used by Maven to display the report under the correct in index.html.
      String getDescription​(Locale locale)
      Returns the description of this report, used by Maven to display report description in index.html.
      String getInputEncoding()
      String getName​(Locale locale)
      Returns the name of this report used by Maven for displaying in index.html.
      String getOutputEncoding()
      String getOutputName()
      Returns the path relative to the target site directory of the this report.
      org.apache.maven.project.MavenProject getProject()
      boolean isExternalReport()
      Returns false if this report will produce output through a supplied Sink, true if it is 'external', producing its output some other way.
      • Methods inherited from class org.apache.maven.reporting.AbstractMavenReport

        closeReport, execute, generate, generate, generate, getOutputDirectory, getReportOutputDirectory, getSink, getSinkFactory, getSiteRenderer, setReportOutputDirectory
      • Methods inherited from class org.apache.maven.plugin.AbstractMojo

        getLog, getPluginContext, setLog, setPluginContext
    • Field Detail

      • script

        @Parameter
        public org.codehaus.plexus.configuration.PlexusConfiguration script
        The script to be used to produce the report, in the scripting language identified by its mimetype or engine attribute.

        The scripting language must be supported by an engine that implements Invocable, and the script, when evaluated, must define functions that correspond to all of the abstract methods of ReportScript, and any of the default methods that it wishes to override.

    • Constructor Detail

      • ReportScriptingMojo

        public ReportScriptingMojo()
    • Method Detail

      • getOutputName

        public String getOutputName()
        Returns the path relative to the target site directory of the this report. This value will be used by Maven to provide a link to the report from index.html.

        Calls setReportScript to ensure that the instance of ReportScript is available. Invokes fun getOutputName(report) defined in the JavaScript snippet associated with the report. No default implementation is provided. User must implement the method in JavaScript.

      • isExternalReport

        public boolean isExternalReport()
        Returns false if this report will produce output through a supplied Sink, true if it is 'external', producing its output some other way.

        Calls setReportScript to ensure that the instance of ReportScript is available. Invokes fun isExternalReport(report) if defined in the javascript snippet associated with the report. Otherwise, the super implementation is invoked effectively.

        Specified by:
        isExternalReport in interface org.apache.maven.reporting.MavenReport
        Overrides:
        isExternalReport in class org.apache.maven.reporting.AbstractMavenReport
      • getName

        public String getName​(Locale locale)
        Returns the name of this report used by Maven for displaying in index.html.

        Calls setReportScript to ensure that the instance of ReportScript is available. Invokes fun getName(report, locale) defined in the javascript snippet associated with the report. No default implementation is provided . User must implement the method in javascript.

      • getDescription

        public String getDescription​(Locale locale)
        Returns the description of this report, used by Maven to display report description in index.html.

        Calls setReportScript to ensure that the instance of ReportScript is available. Invokes fun getDescription(report, locale) defined in the javascript snippet associated with the report. No default implementation is provided . User must implement the method in javascript.

      • getCategoryName

        public String getCategoryName()
        Returns the category name of this report, used by Maven to display the report under the correct in index.html.

        Calls setReportScript to ensure that the instance of ReportScript is available. Invokes fun getCategoryName(report) if defined in the javascript snippet associated with the report. Otherwise, the super implementation is invoked effectively.

        Specified by:
        getCategoryName in interface org.apache.maven.reporting.MavenReport
        Overrides:
        getCategoryName in class org.apache.maven.reporting.AbstractMavenReport
      • canGenerateReport

        public boolean canGenerateReport()
        Returns true if a report can be generated, false otherwise.

        Calls setReportScript to ensure that the instance of ReportScript is available. Invokes fun canGenerateReport(report) if defined in the javascript snippet. Otherwise, the super implementation is invoked effectively.

        Specified by:
        canGenerateReport in interface org.apache.maven.reporting.MavenReport
        Overrides:
        canGenerateReport in class org.apache.maven.reporting.AbstractMavenReport
      • executeReport

        protected void executeReport​(Locale locale)
                              throws org.apache.maven.reporting.MavenReportException

        Calls setReportScript to ensure that the instance of ReportScript is available. Invokes the fun executeReport(report, locale) with the instance of the current report.

        Specified by:
        executeReport in class org.apache.maven.reporting.AbstractMavenReport
        Throws:
        org.apache.maven.reporting.MavenReportException
      • getProject

        public org.apache.maven.project.MavenProject getProject()
        Overrides:
        getProject in class org.apache.maven.reporting.AbstractMavenReport
      • getInputEncoding

        public String getInputEncoding()
        Overrides:
        getInputEncoding in class org.apache.maven.reporting.AbstractMavenReport
      • getOutputEncoding

        public String getOutputEncoding()
        Overrides:
        getOutputEncoding in class org.apache.maven.reporting.AbstractMavenReport
      • exceptionWrap

        public org.apache.maven.reporting.MavenReportException exceptionWrap​(Object object)
        Wraps the input object in a MavenReportException. The exception returned is constructed as follows: 1) If object is null, the exception message indicates the same. 2) If object is already a MavenReportException, return it as is. 3) If object is any other Throwable, set it as the cause for the exception. MavenReportException with object as its cause. 4) If object is a String, set it as the message of the exception. 5) For all other case, the message of the exception is set in this format , Class Name of object: String representation of object.
        Parameters:
        object - to wrap in MavenReportException
        Returns:
        object wrapped inside a MavenReportException