Built-In Types

The Rat Antlib defines a few Ant types that can be used as nested elements to the Report Task as license matchers or license families.

In order to stay compatible with Ant 1.7.1 these types are defined via typedef rather than componentdef which means they can be defined outside of the Report task as well - but they will be completely useless there.

License Matchers

The following types correspond to the built-in license matchers of Rat:

Typename Detected License Corresponding class
asl20 Apache License 2.0 org.apache.rat.analysis.license.ApacheSoftwareLicense20
dojo since Rat Antlib 0.8 License of the Dojo Toolkit org.apache.rat.analysis.license.DojoLicenseHeader
generated Generated documents that don't need a license org.apache.rat.analysis.generation.GeneratedLicenseNotRequired
gpl1 since Rat Antlib 0.9 GNU General Public License, version 1 org.apache.rat.analysis.license.GPL1License
gpl2 since Rat Antlib 0.9 GNU General Public License, version 2 org.apache.rat.analysis.license.GPL2License
gpl3 since Rat Antlib 0.9 GNU General Public License, version 3 org.apache.rat.analysis.license.GPL3License
javadoc Javadocs that don't need a license org.apache.rat.analysis.generation.JavaDocLicenseNotRequired
mit since Rat Antlib 0.9 The MIT License org.apache.rat.analysis.license.MITLicense
oasis since Rat Antlib 0.8 OASIS copyright claim plus derivative work clause org.apache.rat.analysis.license.OASISLicense
w3c W3C Software License org.apache.rat.analysis.license.W3CLicense
w3c-doc W3C Document License org.apache.rat.analysis.license.W3CDocLicense

While these types may technically provide attributes or nested elements you should use them as sole tags.

substringMatcher

since Rat Antlib 0.8

For the simple case where a license can be detected by searching for a given string in a single line of the source code - in fact this is what many built-in implementations do - you can use the substringMatcher type.

Attributes of the Type

Name Description
licenseFamilyCategory Short name of the detected license. Should be at most five characters long if you want to keep the layout of the plain text report. This will be printed next to to the checked file inside the plain text report and creates header-type elements inside the XML report. REQUIRED
licenseFamilyName Long name of the detected license. The value is checked against the list of approved licenses. This will not appear inside the plain text report and creates license-family elements inside the XML report. REQUIRED
notes Additional notes you want to provide. This will not appear inside the plain text report and creates header-sample elements inside the XML report.

Nested Elements Supported by the Type

The substring(s) to look for are specified as nested pattern elements with a substring attribute. You can specifiy multiple pattern elements and the substringMatcher will claim the license matches if at least one substring can be found.

At least one pattern is required.

Example

Taking the example of the custom types page in order to detect

  /**
   * Yet Another Software License, 1.0
   *
   * Lots of text, specifying the users rights, and whatever ...
   */

you could use

<rat:report>
    <fileset dir="src"/>
    <rat:substringMatcher licenseFamilyCategory="YASL1"
             licenseFamilyName="Yet Another Software License, Version 1.0">
        <pattern substring="Yet Another Software License, 1.0"/>
    </rat:substringMatcher>
</rat:report>

fullTextMatcher

since Rat Antlib 0.9

This matcher searches for the full text given, ignoring everything that is not a character or a number (and for US-ASCII characters it is case-insensitive). This allows licenses to be detected that can't be identified by a single line, even if the formatting has been changed.

Attributes of the Type

Name Description
licenseFamilyCategory Short name of the detected license. Should be at most five characters long if you want to keep the layout of the plain text report. This will be printed next to to the checked file inside the plain text report and creates header-type elements inside the XML report. REQUIRED
licenseFamilyName Long name of the detected license. The value is checked against the list of approved licenses. This will not appear inside the plain text report and creates license-family elements inside the XML report. REQUIRED
notes Additional notes you want to provide. This will not appear inside the plain text report and creates header-sample elements inside the XML report.
fullText The license text to look for. Everything that is not a character or a digit will be ignored. REQUIRED unless the text is specified as nested content.

You can also nest the license text directly as content into the type.

Example

Taking the example of the custom types page in order to detect

  /**
   * Yet Another Software License, 1.0
   *
   * Lots of text, specifying the users rights, and whatever ...
   */

you could use

<rat:report>
    <fileset dir="src"/>
    <rat:fullTextMatcher licenseFamilyCategory="YASL1"
             licenseFamilyName="Yet Another Software License, Version 1.0"
             fullText="Yet Another Software License, 1.0 Lots of text, specifying the users rights, and whatever">
    </rat:fullTextMatcher>
</rat:report>

or

<rat:report>
    <fileset dir="src"/>
    <rat:fullTextMatcher licenseFamilyCategory="YASL1"
             licenseFamilyName="Yet Another Software License, Version 1.0">
Yet Another Software License, 1.0

Lots of text, specifying the users rights, and whatever
    </rat:fullTextMatcher>
</rat:report>

License Families

The following types correspond to the built-in license families of Rat:

Typename License Family Corresponding class
academic-free-21 since Rat Antlib 0.8 Academic Free License 2.1 org.apache.rat.license.AcademicFree21LicenseFamily
apache20-license Apache License 2.0 org.apache.rat.license.Apache20LicenseFamily
gpl1-family since Rat Antlib 0.9 GNU General Public License, version 1 org.apache.rat.license.GPL1LicenseFamily
gpl2-family since Rat Antlib 0.9 GNU General Public License, version 2 org.apache.rat.license.GPL2LicenseFamily
gpl3-family since Rat Antlib 0.9 GNU General Public License, version 3 org.apache.rat.license.GPL3LicenseFamily
mit-family since Rat Antlib 0.9 The MIT License org.apache.rat.license.MITLicenseFamily
modified-bsd since Rat Antlib 0.8 Modified BSD License org.apache.rat.license.ModifiedBSDLicenseFamily
oasis-license since Rat Antlib 0.8 OASIS copyright claim plus derivative work clause org.apache.rat.license.OASISLicenseFamily
w3c-doc-license W3C Document License org.apache.rat.license.W3CDocumentLicenseFamily
w3c-soft-license W3C Software License org.apache.rat.license.W3CSoftwareLicenseFamily

While these types may technically provide attributes or nested elements you should use them as sole tags.

approvedLicense

since Rat Antlib 0.8

This wrapper type makes it easy to specify a license name for new approved licenses. The type has a single attribute familyName that must match the license family name returned by the license matcher to make a license approved.

Example

To make the YASL license of the substringMatcher Example approved you'd use

<rat:report>
    <fileset dir="src"/>
    <rat:substringMatcher licenseFamilyCategory="YASL1"
             licenseFamilyName="Yet Another Software License, Version 1.0">
        <pattern substring="Yet Another Software License, 1.0"/>
    </rat:substringMatcher>
    <rat:approvedLicense
             familyName="Yet Another Software License, Version 1.0"/>
</rat:report>