Class ReportScriptingMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.maven.reporting.AbstractMavenReport
org.postgresql.pljava.pgxs.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 (or another JSR 223 script engine) for configuring MavenReport during the LifecyclePhase.SITE.

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

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    org.codehaus.plexus.configuration.PlexusConfiguration
    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
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Queries the script as to whether this report can be generated.
    (package private) boolean
    org.apache.maven.reporting.MavenReportException
    Wraps the input object in a MavenReportException.
    protected void
    Queries the script for the category name of this report, used by Maven to place the report under the correct heading in index.html.
    (package private) String
    Queries the script for the description of this report, to be used by Maven for display in index.html.
    getName(Locale locale)
    Queries the script for the name of this report to be used by Maven for display in index.html.
    Queries the script for the report output path relative to the target site directory.
    org.apache.maven.project.MavenProject
    boolean
    Queries the script to return false if this report will produce output through a supplied Sink, or true if it is 'external', producing its output some other way.
    (package private) boolean

    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • 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 Details

    • ReportScriptingMojo

      public ReportScriptingMojo()
  • Method Details

    • getOutputName

      public String getOutputName()
      Queries the script for the report output path relative to the target site directory.

      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 getOutputName(report) defined by the script snippet associated with the report. No default implementation is provided; the script must implement this method.

    • isExternalReport

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

      Calls setReportScript to ensure that the instance of ReportScript is available. Invokes isExternalReport(report) if defined in the script snippet associated with the report. Otherwise, the implementation inherited by this class is effectively invoked.

      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)
      Queries the script for the name of this report to be used by Maven for display in index.html.

      Calls setReportScript to ensure that the instance of ReportScript is available. Invokes getName(report, locale) defined by the script snippet associated with the report. No default implementation is provided; the script must implement this method.

    • getDescription

      public String getDescription(Locale locale)
      Queries the script for the description of this report, to be used by Maven for display in index.html.

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

    • getCategoryName

      public String getCategoryName()
      Queries the script for the category name of this report, used by Maven to place the report under the correct heading in index.html.

      Calls setReportScript to ensure that the instance of ReportScript is available. Invokes getCategoryName(report) if defined by the script snippet associated with the report. Otherwise, the implementation inherited by this class is effectively invoked.

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

      public boolean canGenerateReport()
      Queries the script as to whether this report can be generated.

      Calls setReportScript to ensure that the instance of ReportScript is available. Invokes canGenerateReport(report) if defined by the script snippet. Otherwise, the implementation inherited by this class is effectively invoked.

      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 its executeReport(report, locale), passing this instance and the supplied locale.

      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
    • isExternalReportDefault

      boolean isExternalReportDefault()
      Default implementation for ReportScript.isExternalReport(ReportScriptingMojo). Invoked if isExternalReport(report) is not defined in the script snippet associated with the report.
    • getCategoryNameDefault

      String getCategoryNameDefault()
      Default implementation of ReportScript.getCategoryName(ReportScriptingMojo). Invoked if getCategoryName(report) is not defined in the script snippet associated with the report.
    • canGenerateReportDefault

      boolean canGenerateReportDefault()
      Default implementation of ReportScript.canGenerateReport(ReportScriptingMojo). Invoked if canGenerateReport(report) is not defined in the script snippet associated with the report.
    • exceptionWrap

      public org.apache.maven.reporting.MavenReportException exceptionWrap(Object object)
      Wraps the input object in a MavenReportException. The exception returned is constructed as follows:
      • If object is null, the exception message indicates the same.
      • If object is already a MavenReportException, it is returned as is.
      • If object is any other Throwable, it is used as the wrapping exception's cause.
      • If object is a String, it is used as the wrapping exception's message.
      • If it is any other object, the wrapping exception's message is set in this format: Class mame of object: String representation of object.
      Parameters:
      object - to wrap in MavenReportException
      Returns:
      object wrapped inside a MavenReportException