Class AbstractRatMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
    Direct Known Subclasses:
    RatCheckMojo, RatReportMojo

    public abstract class AbstractRatMojo
    extends org.apache.maven.plugin.AbstractMojo
    Abstract base class for Mojos, which are running Rat.
    • Field Detail

      • basedir

        @Parameter(property="rat.basedir",
                   defaultValue="${basedir}",
                   required=true)
        private java.io.File basedir
        The base directory, in which to search for files.
      • licenses

        @Parameter
        private IHeaderMatcher[] licenses
        Specifies the licenses to accept. By default, these are added to the default licenses, unless you set addDefaultLicenseMatchers to false.
        Since:
        0.8
      • licenseFamilies

        @Parameter
        private ILicenseFamily[] licenseFamilies
        Specifies the license families to accept.
        Since:
        0.8
      • addDefaultLicenseMatchers

        @Parameter(property="rat.addDefaultLicenseMatchers",
                   defaultValue="true")
        private boolean addDefaultLicenseMatchers
        Whether to add the default list of license matchers.
      • includes

        @Parameter
        private java.lang.String[] includes
        Specifies files, which are included in the report. By default, all files are included.
      • includesFile

        @Parameter(property="rat.includesFile")
        private java.lang.String includesFile
        Specifies a file, from which to read includes. Basically, an alternative to specifying the includes as a list.
      • includesFileCharset

        @Parameter(property="rat.includesFileCharset",
                   defaultValue="${project.build.sourceEncoding}")
        private java.lang.String includesFileCharset
        Specifies the include files character set. Defaults to @code{${project.build.sourceEncoding}), or @code{UTF8}.
      • excludes

        @Parameter
        private java.lang.String[] excludes
        Specifies files, which are excluded in the report. By default, no files are excluded.
      • excludesFile

        @Parameter(property="rat.excludesFile")
        private java.lang.String excludesFile
        Specifies a file, from which to read excludes. Basically, an alternative to specifying the excludes as a list. The excludesFile is assumed to be using the UFT8 character set.
      • excludesFileCharset

        @Parameter(property="rat.excludesFileCharset",
                   defaultValue="${project.build.sourceEncoding}")
        private java.lang.String excludesFileCharset
        Specifies the include files character set. Defaults to @code{${project.build.sourceEncoding}), or @code{UTF8}.
      • useDefaultExcludes

        @Parameter(property="rat.useDefaultExcludes",
                   defaultValue="true")
        private boolean useDefaultExcludes
        Whether to use the default excludes when scanning for files. The default excludes are:
      • useMavenDefaultExcludes

        @Parameter(property="rat.useMavenDefaultExcludes",
                   defaultValue="true")
        private boolean useMavenDefaultExcludes
        Whether to use the Maven specific default excludes when scanning for files. Maven specific default excludes are given by the constant MAVEN_DEFAULT_EXCLUDES: The target directory, the cobertura.ser file, and so on.
      • parseSCMIgnoresAsExcludes

        @Parameter(property="rat.parseSCMIgnoresAsExcludes",
                   defaultValue="true")
        private boolean parseSCMIgnoresAsExcludes
        Whether to parse source code management system (SCM) ignore files and use their contents as excludes. At the moment this works for the following SCMs:
        See Also:
        SourceCodeManagementSystems
      • useEclipseDefaultExcludes

        @Parameter(property="rat.useEclipseDefaultExcludes",
                   defaultValue="true")
        private boolean useEclipseDefaultExcludes
        Whether to use the Eclipse specific default excludes when scanning for files. Eclipse specific default excludes are given by the constant ECLIPSE_DEFAULT_EXCLUDES: The .classpath and .project files, the .settings directory, and so on.
      • useIdeaDefaultExcludes

        @Parameter(property="rat.useIdeaDefaultExcludes",
                   defaultValue="true")
        private boolean useIdeaDefaultExcludes
        Whether to use the IDEA specific default excludes when scanning for files. IDEA specific default excludes are given by the constant IDEA_DEFAULT_EXCLUDES: The *.iml, *.ipr and *.iws files and the .idea directory.
      • excludeSubProjects

        @Parameter(property="rat.excludeSubprojects",
                   defaultValue="true")
        private boolean excludeSubProjects
        Whether to exclude subprojects. This is recommended, if you want a separate apache-rat-plugin report for each subproject.
      • skip

        @Parameter(property="rat.skip",
                   defaultValue="false")
        protected boolean skip
        Will skip the plugin execution, e.g. for technical builds that do not take license compliance into account.
        Since:
        0.11
      • project

        @Parameter(defaultValue="${project}",
                   required=true,
                   readonly=true)
        private org.apache.maven.project.MavenProject project
        Holds the maven-internal project to allow resolution of artifact properties during mojo runs.
    • Constructor Detail

      • AbstractRatMojo

        public AbstractRatMojo()
    • Method Detail

      • getProject

        protected org.apache.maven.project.MavenProject getProject()
        Returns:
        Returns the Maven project.
      • mergeLicenseMatchers

        private java.util.List<IHeaderMatcher> mergeLicenseMatchers()
                                                             throws org.apache.maven.plugin.MojoFailureException,
                                                                    org.apache.maven.plugin.MojoExecutionException
        Returns the set of header matchers to use.
        Returns:
        list of license matchers to use
        Throws:
        org.apache.maven.plugin.MojoFailureException - An error in the plugin configuration was detected.
        org.apache.maven.plugin.MojoExecutionException - An error occurred while calculating the result.
      • logLicenseMatchers

        private void logLicenseMatchers​(java.util.List<IHeaderMatcher> matchers)
      • getResources

        protected IReportable getResources()
                                    throws org.apache.maven.plugin.MojoExecutionException
        Creates an iterator over the files to check.
        Returns:
        A container of files, which are being checked.
        Throws:
        org.apache.maven.plugin.MojoExecutionException - in case of errors. I/O errors result in UndeclaredThrowableExceptions.
      • logAboutIncludedFiles

        private void logAboutIncludedFiles​(java.lang.String[] files)
      • whenDebuggingLogExcludedFiles

        private void whenDebuggingLogExcludedFiles​(org.codehaus.plexus.util.DirectoryScanner ds)
      • setIncludes

        private void setIncludes​(org.codehaus.plexus.util.DirectoryScanner ds)
                          throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getPatternsFromFile

        private java.util.List<java.lang.String> getPatternsFromFile​(java.io.File pFile,
                                                                     java.lang.String pCharset)
                                                              throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • setExcludes

        private void setExcludes​(org.codehaus.plexus.util.DirectoryScanner ds)
                          throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • mergeDefaultExclusions

        private java.util.List<java.lang.String> mergeDefaultExclusions()
                                                                 throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • createReport

        protected java.lang.String createReport​(java.io.InputStream styleSheet)
                                         throws org.apache.maven.plugin.MojoExecutionException,
                                                org.apache.maven.plugin.MojoFailureException
        Creates the report as a string.
        Parameters:
        styleSheet - The style sheet to use when formatting the report
        Returns:
        Report contents
        Throws:
        org.apache.maven.plugin.MojoFailureException - An error in the plugin configuration was detected.
        org.apache.maven.plugin.MojoExecutionException - An error occurred while creating the report.
      • createReport

        protected ClaimStatistic createReport​(java.io.Writer out,
                                              java.io.InputStream style)
                                       throws org.apache.maven.plugin.MojoExecutionException,
                                              org.apache.maven.plugin.MojoFailureException
        Writes the report to the given stream.
        Parameters:
        out - The target writer, to which the report is being written.
        style - The stylesheet to use, or null for raw XML
        Returns:
        the current statistic.
        Throws:
        org.apache.maven.plugin.MojoFailureException - An error in the plugin configuration was detected.
        org.apache.maven.plugin.MojoExecutionException - Another error occurred while creating the report.
      • getConfiguration

        protected ReportConfiguration getConfiguration()
                                                throws org.apache.maven.plugin.MojoFailureException,
                                                       org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoFailureException
        org.apache.maven.plugin.MojoExecutionException
      • mergeApprovedLicenseNames

        private java.util.List<ILicenseFamily> mergeApprovedLicenseNames()
                                                                  throws org.apache.maven.plugin.MojoExecutionException,
                                                                         org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.apache.maven.plugin.MojoFailureException