Package org.apache.rat.anttasks
Class Report
- java.lang.Object
-
- org.apache.tools.ant.ProjectComponent
-
- org.apache.tools.ant.Task
-
- org.apache.rat.anttasks.Report
-
- All Implemented Interfaces:
java.lang.Cloneable
public class Report extends org.apache.tools.ant.TaskA basic Ant task that generates a report on all files specified by the nested resource collection(s).IHeaderMatcher(s) can be specified as nested elements as well.
The attribute
formatdefines the output format and can take the values- xml - Rat's native XML output.
- styled - transforms the XML output using the given stylesheet. The stylesheet attribute must be set as well if this attribute is used.
- plain - plain text using Rat's built-in stylesheet. This is the default.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classReport.AddLicenseHeadersType for the addLicenseHeaders attribute.static classReport.FormatType for the format attribute.
-
Field Summary
Fields Modifier and Type Field Description private booleanaddDefaultLicenseMatchersWhether to add the default list of license matchers.private Report.AddLicenseHeadersaddLicenseHeadersWhether to add license headers.private java.lang.StringcopyrightMessageThe copyright message.private Report.FormatformatWhich format to use.private java.util.ArrayList<IHeaderMatcher>licenseMatchersThe licenses we want to match on.private java.util.ArrayList<ILicenseFamily>licenseNamesprivate org.apache.tools.ant.types.resources.UnionnestedResourceswill hold any nested resource collectionprivate java.io.FilereportFileWhere to send the report.private org.apache.tools.ant.types.ResourcestylesheetWhich stylesheet to use.
-
Constructor Summary
Constructors Constructor Description Report()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(IHeaderMatcher matcher)voidadd(ILicenseFamily license)voidadd(org.apache.tools.ant.types.ResourceCollection rc)Adds resources that will be checked.voidaddConfiguredStylesheet(org.apache.tools.ant.types.resources.Union u)Which stylesheet to use (only meaningful with format='styled').private voidcreateReport(java.io.PrintWriter out)Writes the report to the given stream.voidexecute()Generates the report.private ILicenseFamily[]getApprovedLicenseNames()private java.util.List<IHeaderMatcher>getLicenseMatchers()Flattens all nested matchers plus the default matchers (if required) into a single array.voidsetAddDefaultLicenseMatchers(boolean addDefaultLicenseMatchers)voidsetAddLicenseHeaders(Report.AddLicenseHeaders pAdd)voidsetCopyrightMessage(java.lang.String pMessage)voidsetFormat(Report.Format f)Which format to use.voidsetReportFile(java.io.File f)Where to send the report to.private voidvalidate()validates the task's configuration.-
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
-
-
-
-
Field Detail
-
nestedResources
private org.apache.tools.ant.types.resources.Union nestedResources
will hold any nested resource collection
-
licenseMatchers
private final java.util.ArrayList<IHeaderMatcher> licenseMatchers
The licenses we want to match on.
-
licenseNames
private final java.util.ArrayList<ILicenseFamily> licenseNames
-
addDefaultLicenseMatchers
private boolean addDefaultLicenseMatchers
Whether to add the default list of license matchers.
-
reportFile
private java.io.File reportFile
Where to send the report.
-
format
private Report.Format format
Which format to use.
-
stylesheet
private org.apache.tools.ant.types.Resource stylesheet
Which stylesheet to use.
-
addLicenseHeaders
private Report.AddLicenseHeaders addLicenseHeaders
Whether to add license headers.
-
copyrightMessage
private java.lang.String copyrightMessage
The copyright message.
-
-
Method Detail
-
add
public void add(org.apache.tools.ant.types.ResourceCollection rc)
Adds resources that will be checked.- Parameters:
rc- resource to check.
-
add
public void add(IHeaderMatcher matcher)
- Parameters:
matcher- Adds a license matcher.
-
add
public void add(ILicenseFamily license)
-
setAddDefaultLicenseMatchers
public void setAddDefaultLicenseMatchers(boolean addDefaultLicenseMatchers)
- Parameters:
addDefaultLicenseMatchers- Whether to add the default list of license matchers.
-
setReportFile
public void setReportFile(java.io.File f)
Where to send the report to.- Parameters:
f- report output file.
-
setFormat
public void setFormat(Report.Format f)
Which format to use.- Parameters:
f- format.
-
setAddLicenseHeaders
public void setAddLicenseHeaders(Report.AddLicenseHeaders pAdd)
- Parameters:
pAdd- Whether to add license headers.
-
setCopyrightMessage
public void setCopyrightMessage(java.lang.String pMessage)
- Parameters:
pMessage- copyright message to set.
-
addConfiguredStylesheet
public void addConfiguredStylesheet(org.apache.tools.ant.types.resources.Union u)
Which stylesheet to use (only meaningful with format='styled').- Parameters:
u- stylesheet.
-
execute
public void execute()
Generates the report.- Overrides:
executein classorg.apache.tools.ant.Task
-
validate
private void validate()
validates the task's configuration.
-
createReport
private void createReport(java.io.PrintWriter out) throws java.io.IOException, javax.xml.transform.TransformerException, java.lang.InterruptedException, RatExceptionWrites the report to the given stream.- Parameters:
out- stream to write report to.- Throws:
java.io.IOException- in case of I/O errors.java.lang.InterruptedException- in case of threading errors.javax.xml.transform.TransformerException- in case of XML errors.RatException- in case of general errors.
-
getLicenseMatchers
private java.util.List<IHeaderMatcher> getLicenseMatchers()
Flattens all nested matchers plus the default matchers (if required) into a single array.
-
getApprovedLicenseNames
private ILicenseFamily[] getApprovedLicenseNames()
-
-