Package org.apache.rat.mp
Class AbstractRatMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.apache.rat.mp.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 Summary
Fields Modifier and Type Field Description private boolean
addDefaultLicenseMatchers
Whether to add the default list of license matchers.private java.io.File
basedir
The base directory, in which to search for files.private java.lang.String[]
excludes
Specifies files, which are excluded in the report.private java.lang.String
excludesFile
Specifies a file, from which to read excludes.private java.lang.String
excludesFileCharset
Specifies the include files character set.private boolean
excludeSubProjects
Whether to exclude subprojects.private java.lang.String[]
includes
Specifies files, which are included in the report.private java.lang.String
includesFile
Specifies a file, from which to read includes.private java.lang.String
includesFileCharset
Specifies the include files character set.private ILicenseFamily[]
licenseFamilies
Specifies the license families to accept.private LicenseFamilySpecification[]
licenseFamilyNames
Deprecated.UselicenseFamilies
instead.private HeaderMatcherSpecification[]
licenseMatchers
Deprecated.Uselicenses
instead.private IHeaderMatcher[]
licenses
Specifies the licenses to accept.private boolean
parseSCMIgnoresAsExcludes
Whether to parse source code management system (SCM) ignore files and use their contents as excludes.private org.apache.maven.project.MavenProject
project
Holds the maven-internal project to allow resolution of artifact properties during mojo runs.protected boolean
skip
Will skip the plugin execution, e.g.private boolean
useDefaultExcludes
Whether to use the default excludes when scanning for files.private boolean
useEclipseDefaultExcludes
Whether to use the Eclipse specific default excludes when scanning for files.private boolean
useIdeaDefaultExcludes
Whether to use the IDEA specific default excludes when scanning for files.private boolean
useMavenDefaultExcludes
Whether to use the Maven specific default excludes when scanning for files.
-
Constructor Summary
Constructors Constructor Description AbstractRatMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
createReport(java.io.InputStream styleSheet)
Creates the report as a string.protected ClaimStatistic
createReport(java.io.Writer out, java.io.InputStream style)
Writes the report to the given stream.protected ReportConfiguration
getConfiguration()
private java.util.List<java.lang.String>
getPatternsFromFile(java.io.File pFile, java.lang.String pCharset)
protected org.apache.maven.project.MavenProject
getProject()
protected IReportable
getResources()
Creates an iterator over the files to check.private void
logAboutIncludedFiles(java.lang.String[] files)
private void
logLicenseMatchers(java.util.List<IHeaderMatcher> matchers)
private java.util.List<ILicenseFamily>
mergeApprovedLicenseNames()
private java.util.List<java.lang.String>
mergeDefaultExclusions()
private java.util.List<IHeaderMatcher>
mergeLicenseMatchers()
Returns the set ofheader matchers
to use.private void
setExcludes(org.codehaus.plexus.util.DirectoryScanner ds)
private void
setIncludes(org.codehaus.plexus.util.DirectoryScanner ds)
private void
whenDebuggingLogExcludedFiles(org.codehaus.plexus.util.DirectoryScanner ds)
-
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
-
-
-
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.
-
licenseMatchers
@Deprecated @Parameter private HeaderMatcherSpecification[] licenseMatchers
Deprecated.Uselicenses
instead.Specifies the licenses to accept. Deprecated, uselicenses
instead.
-
licenses
@Parameter private IHeaderMatcher[] licenses
Specifies the licenses to accept. By default, these are added to the default licenses, unless you setaddDefaultLicenseMatchers
to false.- Since:
- 0.8
-
licenseFamilyNames
@Deprecated private LicenseFamilySpecification[] licenseFamilyNames
Deprecated.UselicenseFamilies
instead.The set of approved license family names.
-
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:- meta data files for source code management / revision control systems,
see
SourceCodeManagementSystems
- temporary files used by Maven, see useMavenDefaultExcludes
- configuration files for Eclipse, see useEclipseDefaultExcludes
- configuration files for IDEA, see useIdeaDefaultExcludes
- meta data files for source code management / revision control systems,
see
-
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: Thetarget
directory, thecobertura.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.
-
-
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 ofheader 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, ornull
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
-
-