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.AbstractMojoAbstract base class for Mojos, which are running Rat.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanaddDefaultLicenseMatchersWhether to add the default list of license matchers.private java.io.FilebasedirThe base directory, in which to search for files.private java.lang.String[]excludesSpecifies files, which are excluded in the report.private java.lang.StringexcludesFileSpecifies a file, from which to read excludes.private java.lang.StringexcludesFileCharsetSpecifies the include files character set.private booleanexcludeSubProjectsWhether to exclude subprojects.private java.lang.String[]includesSpecifies files, which are included in the report.private java.lang.StringincludesFileSpecifies a file, from which to read includes.private java.lang.StringincludesFileCharsetSpecifies the include files character set.private ILicenseFamily[]licenseFamiliesSpecifies the license families to accept.private LicenseFamilySpecification[]licenseFamilyNamesDeprecated.UselicenseFamiliesinstead.private HeaderMatcherSpecification[]licenseMatchersDeprecated.Uselicensesinstead.private IHeaderMatcher[]licensesSpecifies the licenses to accept.private booleanparseSCMIgnoresAsExcludesWhether to parse source code management system (SCM) ignore files and use their contents as excludes.protected org.apache.maven.project.MavenProjectprojectHolds the maven-internal project to allow resolution of artifact properties during mojo runs.protected booleanskipWill skip the plugin execution, e.g.private booleanuseDefaultExcludesWhether to use the default excludes when scanning for files.private booleanuseEclipseDefaultExcludesWhether to use the Eclipse specific default excludes when scanning for files.private booleanuseIdeaDefaultExcludesWhether to use the IDEA specific default excludes when scanning for files.private booleanuseMavenDefaultExcludesWhether 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.StringcreateReport(java.io.InputStream styleSheet)Creates the report as a string.protected ClaimStatisticcreateReport(java.io.Writer out, java.io.InputStream style)Writes the report to the given stream.protected ReportConfigurationgetConfiguration()private java.util.List<java.lang.String>getPatternsFromFile(java.io.File pFile, java.lang.String pCharset)protected org.apache.maven.project.MavenProjectgetProject()protected IReportablegetResources()Creates an iterator over the files to check.private voidlogAboutIncludedFiles(java.lang.String[] files)private voidlogLicenseMatchers(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 matchersto use.private voidsetExcludes(org.codehaus.plexus.util.DirectoryScanner ds)private voidsetIncludes(org.codehaus.plexus.util.DirectoryScanner ds)private voidwhenDebuggingLogExcludedFiles(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 basedirThe base directory, in which to search for files.
-
licenseMatchers
@Deprecated @Parameter private HeaderMatcherSpecification[] licenseMatchers
Deprecated.Uselicensesinstead.Specifies the licenses to accept. Deprecated, uselicensesinstead.
-
licenses
@Parameter private IHeaderMatcher[] licenses
Specifies the licenses to accept. By default, these are added to the default licenses, unless you setaddDefaultLicenseMatchersto false.- Since:
- 0.8
-
licenseFamilyNames
@Deprecated private LicenseFamilySpecification[] licenseFamilyNames
Deprecated.UselicenseFamiliesinstead.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 addDefaultLicenseMatchersWhether 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 includesFileCharsetSpecifies 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 excludesFileCharsetSpecifies the include files character set. Defaults to @code{${project.build.sourceEncoding}), or @code{UTF8}.
-
useDefaultExcludes
@Parameter(property="rat.useDefaultExcludes", defaultValue="true") private boolean useDefaultExcludesWhether 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 useMavenDefaultExcludesWhether to use the Maven specific default excludes when scanning for files. Maven specific default excludes are given by the constant MAVEN_DEFAULT_EXCLUDES: Thetargetdirectory, thecobertura.serfile, and so on.
-
parseSCMIgnoresAsExcludes
@Parameter(property="rat.parseSCMIgnoresAsExcludes", defaultValue="true") private boolean parseSCMIgnoresAsExcludesWhether 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 useEclipseDefaultExcludesWhether to use the Eclipse specific default excludes when scanning for files. Eclipse specific default excludes are given by the constant ECLIPSE_DEFAULT_EXCLUDES: The.classpathand.projectfiles, the.settingsdirectory, and so on.
-
useIdeaDefaultExcludes
@Parameter(property="rat.useIdeaDefaultExcludes", defaultValue="true") private boolean useIdeaDefaultExcludesWhether 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,*.iprand*.iwsfiles and the.ideadirectory.
-
excludeSubProjects
@Parameter(property="rat.excludeSubprojects", defaultValue="true") private boolean excludeSubProjectsWhether 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 skipWill 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) protected org.apache.maven.project.MavenProject projectHolds 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 matchersto 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.MojoFailureExceptionCreates 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, ornullfor 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.MojoFailureExceptionorg.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.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
-