Class RatReportMojo

  • 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="rat",
          requiresDependencyResolution=TEST,
          threadSafe=true)
    public class RatReportMojo
    extends AbstractRatMojo
    implements org.apache.maven.reporting.MavenMultiPageReport
    Generates a report with Rat's output.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String inputEncoding
      Specifies the input encoding.
      protected org.apache.maven.artifact.repository.ArtifactRepository localRepository
      The local repository.
      protected java.io.File outputDirectory
      The output directory for the report.
      private java.lang.String outputEncoding
      Specifies the output encoding.
      protected java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> remoteRepositories
      Remote repositories used for the project.
      private java.io.File reportOutputDirectory
      The current report output directory to use
      private org.apache.maven.doxia.sink.Sink sink
      The current sink to use
      private org.apache.maven.doxia.sink.SinkFactory sinkFactory
      The sink factory to use
      protected org.apache.maven.doxia.siterenderer.Renderer siteRenderer
      Doxia Site Renderer component.
      protected org.apache.maven.doxia.tools.SiteTool siteTool
      SiteTool.
      • 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
      RatReportMojo()  
    • Field Detail

      • outputDirectory

        @Parameter(defaultValue="${project.reporting.outputDirectory}",
                   readonly=true,
                   required=true)
        protected java.io.File outputDirectory
        The output directory for the report. Note that this parameter is only evaluated if the goal is run directly from the command line. If the goal is run indirectly as part of a site generation, the output directory configured in the Maven Site Plugin is used instead.
      • inputEncoding

        @Parameter(property="encoding",
                   defaultValue="${project.build.sourceEncoding}",
                   readonly=true)
        private java.lang.String inputEncoding
        Specifies the input encoding.
      • outputEncoding

        @Parameter(property="outputEncoding",
                   defaultValue="${project.reporting.outputEncoding}",
                   readonly=true)
        private java.lang.String outputEncoding
        Specifies the output encoding.
      • localRepository

        @Parameter(defaultValue="${localRepository}",
                   readonly=true,
                   required=true)
        protected org.apache.maven.artifact.repository.ArtifactRepository localRepository
        The local repository.
      • remoteRepositories

        @Parameter(defaultValue="${project.remoteArtifactRepositories}",
                   readonly=true,
                   required=true)
        protected java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> remoteRepositories
        Remote repositories used for the project.
      • siteTool

        @Component
        protected org.apache.maven.doxia.tools.SiteTool siteTool
        SiteTool.
      • siteRenderer

        @Component
        protected org.apache.maven.doxia.siterenderer.Renderer siteRenderer
        Doxia Site Renderer component.
      • sink

        private org.apache.maven.doxia.sink.Sink sink
        The current sink to use
      • sinkFactory

        private org.apache.maven.doxia.sink.SinkFactory sinkFactory
        The sink factory to use
      • reportOutputDirectory

        private java.io.File reportOutputDirectory
        The current report output directory to use
    • Constructor Detail

      • RatReportMojo

        public RatReportMojo()
    • Method Detail

      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException
        This method is called when the report generation is invoked directly as a standalone Mojo.
        Specified by:
        execute in interface org.apache.maven.plugin.Mojo
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if an error occurs when generating the report
        See Also:
        Mojo.execute()
      • createSiteRenderingContext

        private org.apache.maven.doxia.siterenderer.SiteRenderingContext createSiteRenderingContext​(java.util.Locale locale)
                                                                                             throws org.apache.maven.reporting.MavenReportException,
                                                                                                    java.io.IOException
        Throws:
        org.apache.maven.reporting.MavenReportException
        java.io.IOException
      • generate

        @Deprecated
        public void generate​(org.codehaus.doxia.sink.Sink sink,
                             java.util.Locale locale)
                      throws org.apache.maven.reporting.MavenReportException
        Deprecated.
        Generate a report.
        Specified by:
        generate in interface org.apache.maven.reporting.MavenReport
        Parameters:
        sink - the sink to use for the generation.
        locale - the wanted locale to generate the report, could be null.
        Throws:
        org.apache.maven.reporting.MavenReportException - if any
      • generate

        @Deprecated
        public void generate​(org.apache.maven.doxia.sink.Sink sink,
                             java.util.Locale locale)
                      throws org.apache.maven.reporting.MavenReportException
        Deprecated.
        Generate a report.
        Parameters:
        sink -
        locale -
        Throws:
        org.apache.maven.reporting.MavenReportException
      • generate

        public void generate​(org.apache.maven.doxia.sink.Sink sink,
                             org.apache.maven.doxia.sink.SinkFactory sinkFactory,
                             java.util.Locale locale)
                      throws org.apache.maven.reporting.MavenReportException
        This method is called when the report generation is invoked by maven-site-plugin.
        Specified by:
        generate in interface org.apache.maven.reporting.MavenMultiPageReport
        Parameters:
        sink -
        sinkFactory -
        locale -
        Throws:
        org.apache.maven.reporting.MavenReportException
      • getCategoryName

        public java.lang.String getCategoryName()
        Specified by:
        getCategoryName in interface org.apache.maven.reporting.MavenReport
        Returns:
        CATEGORY_PROJECT_REPORTS
      • getReportOutputDirectory

        public java.io.File getReportOutputDirectory()
        Specified by:
        getReportOutputDirectory in interface org.apache.maven.reporting.MavenReport
      • setReportOutputDirectory

        public void setReportOutputDirectory​(java.io.File reportOutputDirectory)
        Specified by:
        setReportOutputDirectory in interface org.apache.maven.reporting.MavenReport
      • getOutputDirectory

        protected java.lang.String getOutputDirectory()
      • getSiteRenderer

        protected org.apache.maven.doxia.siterenderer.Renderer getSiteRenderer()
      • getInputEncoding

        protected java.lang.String getInputEncoding()
        Gets the input files encoding.
        Returns:
        The input files encoding, never null.
      • getOutputEncoding

        protected java.lang.String getOutputEncoding()
        Gets the effective reporting output files encoding.
        Returns:
        The effective reporting output file encoding, never null.
      • closeReport

        protected void closeReport()
        Actions when closing the report.
      • getSink

        public org.apache.maven.doxia.sink.Sink getSink()
        Returns:
        the sink used
      • getSinkFactory

        public org.apache.maven.doxia.sink.SinkFactory getSinkFactory()
        Returns:
        the sink factory used
      • isExternalReport

        public boolean isExternalReport()
        Specified by:
        isExternalReport in interface org.apache.maven.reporting.MavenReport
        Returns:
        false by default.
        See Also:
        MavenReport.isExternalReport()
      • canGenerateReport

        public boolean canGenerateReport()
        Specified by:
        canGenerateReport in interface org.apache.maven.reporting.MavenReport
      • getRatVersion

        private java.lang.String getRatVersion()
        Searches for a Rat artifact in the dependency list and returns its version.
        Returns:
        Version number, if found, or null.
      • executeReport

        protected void executeReport​(java.util.Locale locale)
                              throws org.apache.maven.reporting.MavenReportException
        Writes the report to the Doxia sink.
        Parameters:
        locale - The locale to use for writing the report.
        Throws:
        org.apache.maven.reporting.MavenReportException - Writing the report failed.
      • getBundle

        private java.util.ResourceBundle getBundle​(java.util.Locale locale)
        Returns the reports bundle
        Parameters:
        locale - Requested locale of the bundle
        Returns:
        The bundle, which is used to read localized strings.
      • getDescription

        public java.lang.String getDescription​(java.util.Locale locale)
        Returns the reports description.
        Specified by:
        getDescription in interface org.apache.maven.reporting.MavenReport
        Parameters:
        locale - Requested locale of the bundle
        Returns:
        Report description, as given by the key "report.rat.description" in the bundle.
      • getName

        public java.lang.String getName​(java.util.Locale locale)
        Returns the reports name.
        Specified by:
        getName in interface org.apache.maven.reporting.MavenReport
        Parameters:
        locale - Requested locale of the bundle
        Returns:
        Report name, as given by the key "report.rat.name" in the bundle.
      • getOutputName

        public java.lang.String getOutputName()
        Returns the reports file name.
        Specified by:
        getOutputName in interface org.apache.maven.reporting.MavenReport
        Returns:
        "rat-report"