These examples assume you have installed the Rat Antlib in a way that provides the Report task in the XML namespace associated with the prefix rat.

Run Rat in default configuration on all files in directory src.

    <fileset dir="src"/>

The report will be written to Ant's logging system.

This corresponds to the command line

java -jar apache-rat-0.16.1.jar src

except that Ant's default excludes will be applied when looking for documents to check.

Run Rat on multiple directories

    <fileset dir="module1/src/main"/>
    <fileset dir="module2/src/test"/>

Adding license headers

The equivalent of

java -jar apache-rat-0.16.1.jar --addlicense
  --copyright "Copyright 2008 Foo"


<rat:report addLicenseHeaders="true"
            coprightMessage="Copyright 2008 Foo">
    <fileset dir="/path/to/project"/>

Create a styled HTML report

<rat:report format="styled" reportFile="rat.html">
    <fileset dir="src"/>
        <file file="my/rat-xml-2-html.xslt"/>

Run Rat on a tarball located on a webserver

            <url url="http://example.org/some.tar.gz"/>

Run Rat but make the Apache License Version 2.0 the only one accepted

<rat:report addDefaultLicenseMatchers="false">
    <fileset dir="src"/>

Run Rat on all files in src that have been modified today

<rat:report xmlns:rat="antlib:org.apache.rat.anttasks">
        <fileset dir="src"/>
        <date when="after" datetime="${DSTAMP}" pattern="yyyyMMdd"/>

Make Rat only detect your custom license and mark this license approved.

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