About Apache Rat™

Rat audits software distributions, with a special interest in headers. If this isn't quite what you're looking for then take a look at the other products developed by Apache Creadur™, including Apache Whisker™ which audits and generates legal (for example LICENSE) documents for complex software distributions.

Running from the Command Line

Run from the command line with:

java -jar apache-rat/target/apache-rat-0.17-SNAPSHOT.jar --help

This will output a help message detailing the command line options available to you.

Adding license headers

Rat can be used to automatically add license headers to files that do not currently have them. Only files that are not excluded by the Rat configurations will be affected.

To add license headers use a command such as:

java -jar apache-rat/target/apache-rat-0.17-SNAPSHOT.jar --addlicense
  --copyright "Copyright 2008 Foo" --force
  /path/to/project

This command will add the license header directly to the source files. If you prefer to see which files will be changed and how then remove the "--force" option.

Using multiple excludes from a file

It is common to use the Rat with the Maven or Ant plugins and specify a series of files to exclude (such as a README or version control files). If you are using the Rat application instead of a plugin you can specify a series of regex excludes in a file and specify that with the --exclude-file option.

java -jar apache-rat/target/apache-rat-0.17-SNAPSHOT.jar
 --exclude-file /path/to/project/.rat-excludes
  /path/to/project

Command Line Options

INFO: Apache Creadur RAT 0.17-SNAPSHOT (Apache Software Foundation)
usage: java -jar apache-rat/target/apache-rat-0.17-SNAPSHOT.jar [options] [DIR|ARCHIVE]

====== Available Options ======
 -?,--help                                            Print help for the RAT command line interface and exit.
 -a                                                   [Deprecated for removal since 0.17: Use --edit-license instead.]
 -A,--addLicense                                      [Deprecated for removal since 0.17: Use --edit-license instead.]
                                                      Add the default license header to any file with an unknown license
                                                      that is not in the exclusion list.
 -c,--copyright <arg>                                 [Deprecated for removal since 0.17: Use --edit-copyright instead.]
                                                      The copyright message to use in the license headers.
    --config <File>                                   File names for system configuration. Multiple values may be
                                                      specified. Note that '--' or a following option is required when
                                                      using this parameter.
    --configuration-no-defaults                       Ignore default configuration.
 -d,--dir <DirOrArchive>                              [Deprecated for removal since 0.17: Use the standard '--' to
                                                      signal the end of arguments.] Used to indicate end of list when
                                                      using options that take multiple arguments.
    --dry-run                                         If set do not update the files but generate the reports.
 -e,--exclude <Expression>                            [Deprecated for removal since 0.17: Use --input-exclude instead.]
                                                      Excludes files matching <Expression>. Multiple values may be
                                                      specified. Note that '--' or a following option is required when
                                                      using this parameter.
 -E,--exclude-file <File>                             [Deprecated for removal since 0.17: Use --input-exclude-file
                                                      instead.] Reads <Expression> entries from a file. Entries will be
                                                      excluded from processing.
    --edit-copyright <arg>                            The copyright message to use in the license headers. Usually in
                                                      the form of "Copyright 2008 Foo".  Only valid with --edit-license
    --edit-license                                    Add the default license header to any file with an unknown license
                                                      that is not in the exclusion list. By default new files will be
                                                      created with the license header, to force the modification of
                                                      existing files use the --edit-overwrite option.
    --edit-overwrite                                  Forces any changes in files to be written directly to the source
                                                      files (i.e. new files are not created). Only valid with
                                                      --edit-license
 -f,--force                                           [Deprecated for removal since 0.17: Use --edit-overwrite instead.]
                                                      Forces any changes in files to be written directly to the source
                                                      files (i.e. new files are not created).
    --help-licenses                                   Print information about registered licenses.
    --include <Expression>                            [Deprecated for removal since 0.17: Use --input-include instead.]
                                                      Includes files matching <Expression>. Will override excluded
                                                      files. Multiple values may be specified. Note that '--' or a
                                                      following option is required when using this parameter.
    --includes-file <File>                            [Deprecated for removal since 0.17: Use --input-include-file
                                                      instead.] Reads <Expression> entries from a file. Entries will be
                                                      excluded from processing.
    --input-exclude <Expression>                      Excludes files matching <Expression>. Multiple values may be
                                                      specified. Note that '--' or a following option is required when
                                                      using this parameter.
    --input-exclude-file <File>                       Reads <Expression> entries from a file. Entries will be excluded
                                                      from processing.
    --input-exclude-parsed-scm <StandardCollection>   Parse SCM based exclusion files to exclude specified files and
                                                      directories. Multiple values may be specified. Note that '--' or a
                                                      following option is required when using this parameter.
    --input-exclude-std <StandardCollection>          Excludes files defined in standard collections based on commonly
                                                      occurring groups. Multiple values may be specified. Note that '--'
                                                      or a following option is required when using this parameter.
    --input-include <Expression>                      Includes files matching <Expression>. Will override excluded
                                                      files. Multiple values may be specified. Note that '--' or a
                                                      following option is required when using this parameter.
    --input-include-file <File>                       Reads <Expression> entries from a file. Entries will override
                                                      excluded files.
    --input-include-std <StandardCollection>          Includes files defined in standard collections based on commonly
                                                      occurring groups. Will override excluded files. Multiple values
                                                      may be specified. Note that '--' or a following option is required
                                                      when using this parameter.
    --license-families-approved <FamilyID>            The approved License Family IDs. These licenses families will be
                                                      added to the list of approved licenses families. Multiple values
                                                      may be specified. Note that '--' or a following option is required
                                                      when using this parameter.
    --license-families-approved-file <File>           Name of file containing the approved family IDs.
    --license-families-denied <FamilyID>              The denied License family IDs. These license families will be
                                                      removed from the list of approved licenses. Multiple values may be
                                                      specified. Note that '--' or a following option is required when
                                                      using this parameter.
    --license-families-denied-file <File>             Name of file containing the denied license IDs.
    --licenses <File>                                 [Deprecated for removal since 0.17: Use --config instead.] File
                                                      names for system configuration. Multiple values may be specified.
                                                      Note that '--' or a following option is required when using this
                                                      parameter.
    --licenses-approved <LicenseID>                   The approved License IDs. These licenses will be added to the list
                                                      of approved licenses. Multiple values may be specified. Note that
                                                      '--' or a following option is required when using this parameter.
    --licenses-approved-file <File>                   Name of file containing the approved License IDs.
    --licenses-denied <LicenseID>                     The denied License IDs. These licenses will be removed from the
                                                      list of approved licenses. Once licenses are removed they can not
                                                      be added back. Multiple values may be specified. Note that '--' or
                                                      a following option is required when using this parameter.
    --licenses-denied-file <File>                     Name of file containing the denied license IDs.
    --list-families <LicenseFilter>                   [Deprecated for removal since 0.17: Use --output-families
                                                      instead.] List the defined license families. (Default value =
                                                      NONE)
    --list-licenses <LicenseFilter>                   [Deprecated for removal since 0.17: Use --output-licenses
                                                      instead.] List the defined licenses. (Default value = NONE)
    --log-level <LogLevel>                            sets the log level. (Default value = WARN)
    --no-default-licenses                             [Deprecated for removal since 0.17: Use
                                                      --configuration-no-defaults instead.] Ignore default
                                                      configuration.
 -o,--out <File>                                      [Deprecated for removal since 0.17: Use --output-file instead.]
                                                      Define the output file where to write a report to. (Default value
                                                      = System.out)
    --output-archive <ProcessingType>                 Specifies the level of detail in ARCHIVE file reporting. (Default
                                                      value = NOTIFICATION)
    --output-families <LicenseFilter>                 List the defined license families. (Default value = NONE)
    --output-file <File>                              Define the output file where to write a report to. (Default value
                                                      = System.out)
    --output-licenses <LicenseFilter>                 List the defined licenses. (Default value = NONE)
    --output-standard <ProcessingType>                Specifies the level of detail in STANDARD file reporting. (Default
                                                      value = ABSENCE)
    --output-style <StyleSheet>                       XSLT stylesheet to use when creating the report. Either an
                                                      external xsl file may be specified or one of the internal named
                                                      sheets.
 -s,--stylesheet <StyleSheet>                         [Deprecated for removal since 0.17: Use --output-style instead.]
                                                      XSLT stylesheet to use when creating the report.
    --scan-hidden-directories                         [Deprecated for removal since 0.17: Use --input-include-std with
                                                      'HIDDEN_DIR' argument instead.] Scans hidden directories.
 -x,--xml                                             [Deprecated for removal since 0.17: Use --output-style with the
                                                      'xml' argument instead.] forces XML output rather than the textual
                                                      report.

====== Argument Types ======

<DirOrArchive>
     A directory or archive file to scan.

<Expression>
     A file matching pattern usually of the form used in Ant build files and '.gitignore' files (see
         https://ant.apache.org/manual/dirtasks.html#patterns for examples). Regular expression patterns may be
         specified by surrounding the pattern with '%regex[' and ']'. For example '%regex[[A-Z].*]' would match files
         and directories that start with uppercase latin letters.

<FamilyID>
     The ID for a license family.

<File>
     A file name.

<LicenseFilter>
     A defined filter for the licenses to include. Valid values: ALL, APPROVED, NONE.

<LicenseID>
     The ID for a license.

<LogLevel>
     The log level to use. Valid values DEBUG, INFO, WARN, ERROR, OFF.

<ProcessingType>
     Specifies how to process file types. Valid values are:
         NOTIFICATION: List file as present

         PRESENCE: List any licenses found

         ABSENCE: List licenses found and any unknown licences

<StandardCollection>
     Defines standard expression patterns (see above). Valid values are:
         ALL: All of the Standard Excludes combined.

         ARCH: The files and directories created by an ARCH source code control based tool.

         BAZAAR: The files and directories created by a Bazaar source code control based tool.

         BITKEEPER: The files and directories created by a Bitkeeper source code control based tool.

         CVS: The files and directories created by a CVS source code control based tool.

         DARCS: The files and directories created by a DARCS source code control based tool.

         ECLIPSE: The files and directories created by an Eclipse IDE based tool.

         GIT: The files and directories created by GIT source code control to support GIT, also processes files listed
         in '.gitignore'.

         HIDDEN_DIR: The hidden directories. Directories with names that start with '.'

         HIDDEN_FILE: The hidden files. Directories with names that start with '.'

         IDEA: The files and directories created by an IDEA IDE based tool.

         MAC: The .DS_Store files MAC computer.

         MAVEN: The files and directories created by Maven build system based project.

         MERCURIAL: The files and directories created by a Mercurial source code control based tool.

         MISC: The set of miscellaneous files generally left by editors and the like.

         MKS: The files and directories created by an MKS source code control based tool.

         RCS: The files and directories created by a RCS source code control based tool.

         SCCS: The files and directories created by a SCCS source code control based tool.

         SERENA_DIMENSIONS_10: The files and directories created by a Serena Dimensions V10 change control system based
         tool.

         STANDARD_PATTERNS: A standard collection of generally accepted patterns to ignore.

         STANDARD_SCMS: A standard collection of SCMs

         SUBVERSION: The files and directories created by a Subversion source code control based tool.

         SURROUND_SCM: The files and directories created by a Surround SCM source code control based tool.

         VSS: The files and directories created by a Visual Source Safe source code control based tool.

<StyleSheet>
     Either an external xsl file or one of the internal named sheets. Internal sheets are:
         plain-rat: The default style.

         missing-headers: Produces a report of files that are missing headers.

         unapproved-licenses: Produces a report of the files with unapproved licenses.

         xml: Produces output in pretty-printed XML.

====== Standard Collections ======


<ALL>
     All of the Standard Excludes combined.
     File patterns: **/MANIFEST.MF, *.ipr, **/ChangeSet/**, **/TAGS/**, .classpath, **/*.old, pom.xml.releaseBackup,
         **/.del-*, **/*$, release.properties, .settings/**, **/BitKeeper/**, **/CVS.adm/**, **/*.so, **/*.rej,
         **/.bzr/**, **/*.elc, .checkstyle, **/._*, target/**, **/*~, .repository, *.iws, **/.svn/**, build.log,
         **/project.pj, **/-darcs-backup*, .project, **/*.ln, **/.metadata/**, .idea/**, **/cvslog.*, **/.make.state,
         **/core, .bzrignore, **/CVS/**, **/%*%, **/.git/**, **/_$*, .mvn/**, **/*.BAK, **/.hg/**, **/.arch-ids/**,
         .hgignore, **/*.o, **/SCCS/**, **/,*, .factorypath, **/*.Z, **/.#*, **/vssver.scc, **/#*#, **/*.a, *.iml,
         **/RCS/**, **/*.bak, cobertura.ser, **/*.orig, **/.darcs-temp-mail, **/.nse_depinfo, **/RCSLOG/**, **/*.exe,
         **/tags/**, **/.gitignore, **/.MySCMServerInfo, **/#*, **/*.obj, **/_darcs/**, **/.darcsrepo/**, **/.DS_Store,
         **/.cvsignore
     Provides a path matcher: true
     Provides a file processor: true

<ARCH>
     The files and directories created by an ARCH source code control based tool.
     File patterns: **/.arch-ids/**
     Provides a path matcher: false
     Provides a file processor: false

<BAZAAR>
     The files and directories created by a Bazaar source code control based tool.
     File patterns: **/.bzr/**, .bzrignore
     Provides a path matcher: false
     Provides a file processor: true

<BITKEEPER>
     The files and directories created by a Bitkeeper source code control based tool.
     File patterns: **/BitKeeper/**, **/ChangeSet/**
     Provides a path matcher: false
     Provides a file processor: false

<CVS>
     The files and directories created by a CVS source code control based tool.
     File patterns: **/TAGS/**, **/_$*, **/*.old, **/*.BAK, **/.del-*, **/*$, **/*.o, **/SCCS/**, **/,*, **/CVS.adm/**,
         **/*.so, **/*.rej, **/*.Z, **/.#*, **/*.elc, **/*.a, **/*~, **/RCS/**, **/*.bak, **/*.orig, **/.nse_depinfo,
         **/RCSLOG/**, **/*.exe, **/*.ln, **/tags/**, **/#*, **/*.obj, **/cvslog.*, **/.make.state, **/core, **/CVS/**,
         **/.cvsignore
     Provides a path matcher: false
     Provides a file processor: true

<DARCS>
     The files and directories created by a DARCS source code control based tool.
     File patterns: **/_darcs/**, **/.darcsrepo/**, **/-darcs-backup*, **/.darcs-temp-mail
     Provides a path matcher: false
     Provides a file processor: false

<ECLIPSE>
     The files and directories created by an Eclipse IDE based tool.
     File patterns: .classpath, .factorypath, .checkstyle, .project, .settings/**
     Provides a path matcher: false
     Provides a file processor: false

<GIT>
     The files and directories created by GIT source code control to support GIT, also processes files listed in
         '.gitignore'.
     File patterns: **/.git/**, **/.gitignore
     Provides a path matcher: false
     Provides a file processor: true

<HIDDEN_DIR>
     The hidden directories. Directories with names that start with '.'
     File patterns: <none>
     Provides a path matcher: true
     Provides a file processor: false

<HIDDEN_FILE>
     The hidden files. Directories with names that start with '.'
     File patterns: <none>
     Provides a path matcher: true
     Provides a file processor: false

<IDEA>
     The files and directories created by an IDEA IDE based tool.
     File patterns: *.ipr, *.iml, *.iws, .idea/**
     Provides a path matcher: false
     Provides a file processor: false

<MAC>
     The .DS_Store files MAC computer.
     File patterns: **/.DS_Store
     Provides a path matcher: false
     Provides a file processor: false

<MAVEN>
     The files and directories created by Maven build system based project.
     File patterns: **/MANIFEST.MF, .repository, pom.xml.releaseBackup, .mvn/**, build.log, target/**, cobertura.ser,
         release.properties
     Provides a path matcher: false
     Provides a file processor: false

<MERCURIAL>
     The files and directories created by a Mercurial source code control based tool.
     File patterns: **/.hg/**, .hgignore
     Provides a path matcher: false
     Provides a file processor: true

<MISC>
     The set of miscellaneous files generally left by editors and the like.
     File patterns: **/*~, **/%*%, **/.#*, **/._*, **/#*#
     Provides a path matcher: false
     Provides a file processor: false

<MKS>
     The files and directories created by an MKS source code control based tool.
     File patterns: **/project.pj
     Provides a path matcher: false
     Provides a file processor: false

<RCS>
     The files and directories created by a RCS source code control based tool.
     File patterns: **/RCS/**
     Provides a path matcher: false
     Provides a file processor: false

<SCCS>
     The files and directories created by a SCCS source code control based tool.
     File patterns: **/SCCS/**
     Provides a path matcher: false
     Provides a file processor: false

<SERENA_DIMENSIONS_10>
     The files and directories created by a Serena Dimensions V10 change control system based tool.
     File patterns: **/.metadata/**
     Provides a path matcher: false
     Provides a file processor: false

<STANDARD_PATTERNS>
     A standard collection of generally accepted patterns to ignore.
     File patterns: **/ChangeSet/**, **/TAGS/**, **/*.old, **/.del-*, **/*$, **/BitKeeper/**, **/CVS.adm/**, **/*.so,
         **/*.rej, **/.bzr/**, **/*.elc, **/._*, **/*~, **/.svn/**, **/project.pj, **/-darcs-backup*, **/*.ln,
         **/.metadata/**, **/cvslog.*, **/.make.state, **/core, .bzrignore, **/CVS/**, **/%*%, **/.git/**, **/_$*,
         **/*.BAK, **/.hg/**, **/.arch-ids/**, .hgignore, **/*.o, **/SCCS/**, **/,*, **/*.Z, **/.#*, **/vssver.scc,
         **/#*#, **/*.a, **/RCS/**, **/*.bak, **/*.orig, **/.darcs-temp-mail, **/.nse_depinfo, **/RCSLOG/**, **/*.exe,
         **/tags/**, **/.gitignore, **/.MySCMServerInfo, **/#*, **/*.obj, **/_darcs/**, **/.darcsrepo/**, **/.DS_Store,
         **/.cvsignore
     Provides a path matcher: false
     Provides a file processor: true

<STANDARD_SCMS>
     A standard collection of SCMs
     File patterns: **/.git/**, **/TAGS/**, **/_$*, **/*.old, **/*.BAK, **/.del-*, **/.hg/**, **/*$, .hgignore, **/*.o,
         **/SCCS/**, **/,*, **/CVS.adm/**, **/*.so, **/*.rej, **/*.Z, **/.#*, **/.bzr/**, **/*.elc, **/*.a, **/*~,
         **/RCS/**, **/*.bak, **/.svn/**, **/*.orig, **/.nse_depinfo, **/RCSLOG/**, **/*.exe, **/*.ln, **/tags/**,
         **/.gitignore, **/#*, **/*.obj, **/cvslog.*, **/.make.state, **/core, .bzrignore, **/CVS/**, **/.cvsignore
     Provides a path matcher: false
     Provides a file processor: true

<SUBVERSION>
     The files and directories created by a Subversion source code control based tool.
     File patterns: **/.svn/**
     Provides a path matcher: false
     Provides a file processor: false

<SURROUND_SCM>
     The files and directories created by a Surround SCM source code control based tool.
     File patterns: **/.MySCMServerInfo
     Provides a path matcher: false
     Provides a file processor: false

<VSS>
     The files and directories created by a Visual Source Safe source code control based tool.
     File patterns: **/vssver.scc
     Provides a path matcher: false
     Provides a file processor: false

A path matcher will match specific information about the file.

A file processor will process the associated "ignore" file for include and exclude directives

====== Notes ======

1. Rat highlights possible issues.
2. Rat reports require interpretation.
3. Rat often requires some tuning before it runs well against a project.
4. Rat relies on heuristics: it may miss issues

Styling output

Rat allows you to style the output as you see fit. Three stylesheets are included in the rat package.

These stylesheets can be specified using options in the command line, Maven or Ant clients.