blob: 7fd872b357994a1cb33f2dffeac9f4f9544cc4b5 [file] [log] [blame]
<!DOCTYPE html>
<!--
| Generated by Apache Maven Doxia Site Renderer 2.0.0 from src/site/apt/index.apt.vm at 2025-09-21
| Rendered using Apache Maven Fluido Skin 2.1.0
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="generator" content="Apache Maven Doxia Site Renderer 2.0.0" />
<meta name="author" content="Apache RAT Overview" />
<title>Apache RAT Ant Task Library – Apache RAT\u2122 Task Library for Apache Ant</title>
<link rel="stylesheet" href="./css/apache-maven-fluido-2.1.0.min.css" />
<link rel="stylesheet" href="./css/site.css" />
<link rel="stylesheet" href="./css/print.css" media="print" />
<script src="./js/apache-maven-fluido-2.1.0.min.js"></script>
<link href="https://creadur.apache.org/font/matesc.css" type="text/css" rel="stylesheet" />
</head>
<body>
<a class="github-fork-ribbon right-top" href="https://github.com/apache/creadur-rat" data-ribbon="Fork me on GitHub">Fork me on GitHub</a>
<div class="container-fluid container-fluid-top">
<header>
<div id="banner">
<div class="pull-left"><div id="bannerLeft"><h1><a href="https://www.apache.org/"><img src="https://www.apache.org/img/asf_logo.png" alt="The Apache Software Foundation" /> Apache RAT</a></h1></div></div>
<div class="pull-right"></div>
<div class="clear"><hr/></div>
</div>
<div id="breadcrumbs">
<ul class="breadcrumb">
<li id="publishDate">Last Published: 2025-09-21<span class="divider">|</span>
</li>
<li id="projectVersion">Version: 0.17-SNAPSHOT<span class="divider">|</span></li>
<li><a href="https://www.apache.org/">Apache</a><span class="divider">/</span></li>
<li><a href="../../">Creadur</a><span class="divider">/</span></li>
<li><a href="../">RAT</a><span class="divider">/</span></li>
<li><a href="index.html">Apache RAT\u2122 Task Library for Apache Ant</a><span class="divider">/</span></li>
<li class="active">Apache RAT Ant Task Library</li>
</ul>
</div>
</header>
<div class="row-fluid">
<header id="leftColumn" class="span2">
<nav class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Parent Project</li>
<li><a href="../index.html">Apache Creadur RAT</a></li>
<li class="nav-header">Overview</li>
<li class="active"><a>Introduction</a></li>
<li><a href="report.html">Report Task</a></li>
<li class="nav-header">Examples</li>
<li><a href="examples/basic.html">Basic Usage</a></li>
<li class="nav-header">Project Documentation</li>
<li><a href="project-info.html"><span class="icon-chevron-right"></span>Project Information</a></li>
<li><a href="project-reports.html"><span class="icon-chevron-right"></span>Project Reports</a></li>
<li class="nav-header">Apache RAT™</li>
<li><a href="../index.html">Introducing RAT</a></li>
<li><a href="../download_rat.cgi">Downloads</a></li>
<li><a href="../changes.html">Changes</a></li>
<li class="nav-header">RAT from the Command Line</li>
<li><a href="../apache-rat/index.html">Command Line Introduction</a></li>
<li><a href="../apache-rat/cli_options.html">Command Line Options</a></li>
<li><a href="../apache-rat/env_vars.html">Environment Variables</a></li>
<li><a href="../apache-rat-core/exclusion_expression.html">Exclusion Expressions</a></li>
<li><a href="../apache-rat/standard_collections.html">Standard Collections</a></li>
<li class="nav-header">RAT from Ant</li>
<li><a href="../apache-rat-tasks/index.html">Ant Task Introduction</a></li>
<li><a href="../apache-rat-tasks/ant_options.html">Ant Elements and Attributes</a></li>
<li class="nav-header">RAT from Maven</li>
<li><a href="../apache-rat-plugin/index.html">Maven Plugin Introduction</a></li>
<li><a href="../apache-rat-plugin/mvn_options.html">Maven Options</a></li>
<li><a href="../apache-rat-plugin/examples/index.html">Maven Examples</a></li>
<li class="nav-header">Configuring RAT</li>
<li><a href="../apache-rat/name_xref.html">Option Name Cross Reference</a></li>
<li><a href="../apache-rat/default_licenses.html">Default Licenses</a></li>
<li><a href="../apache-rat/default_matchers.html">Default Matchers</a></li>
<li><a href="../license_def.html">Defining New Licenses</a></li>
<li><a href="../apache-rat/xsd.html">Configuration XSD</a></li>
<li><a href="https://gitbox.apache.org/repos/asf/creadur-rat/blob/master/apache-rat-core/src/main/resources/org/apache/rat/default.xml">Default Configuration</a></li>
<li><a href="../apache-rat/detecting_generated_files.html">Detecting Generated Files</a></li>
<li class="nav-header">RAT Output</li>
<li><a href="../apache-rat/output/example.html">Standard Output Example</a></li>
<li><a href="https://gitbox.apache.org/repos/asf/creadur-rat/blob/master/apache-rat-core/src/main/resources/org/apache/rat/rat-report.xsd">Output XSD</a></li>
<li><a href="https://gitbox.apache.org/repos/asf/creadur-rat/blob/master/apache-rat-core/src/main/resources/org/apache/rat/plain-rat.xsl">XSLT - Plain text</a></li>
<li><a href="https://gitbox.apache.org/repos/asf/creadur-rat/blob/master/apache-rat-core/src/main/resources/org/apache/rat/missing-headers.xsl">XSLT - Missing headers list</a></li>
<li><a href="https://gitbox.apache.org/repos/asf/creadur-rat/blob/master/apache-rat-core/src/main/resources/org/apache/rat/unapproved-licenses.xsl">XSLT - Unapproved licenses list</a></li>
<li class="nav-header">Developing RAT</li>
<li><a href="../architecture.html">Architecture</a></li>
<li><a href="../apidocs/index.html">Javadocs</a></li>
<li><a href="../apache-rat-core/development/document_name.html">Document Name concept</a></li>
<li><a href="../development/ui_implementation.html">UI Development</a></li>
<li><a href="../apache-rat-core/development/write_file_processor.html">Writing a File Processor</a></li>
<li class="nav-header">Apache Creadur™</li>
<li><a href="../..">Creadur Project Home</a></li>
<li><a href="../../tentacles">Apache Tentacles</a></li>
<li><a href="../../whisker">Apache Whisker</a></li>
<li><a href="https://www.apache.org/security/">Security</a></li>
<li><a href="https://www.apache.org/licenses/">License</a></li>
<li><a href="https://privacy.apache.org/policies/privacy-policy-public.html">Privacy</a></li>
<li><a href="https://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li>
<li><a href="https://www.apache.org/foundation/thanks.html">Thanks</a></li>
<li class="nav-header">The Apache Software Foundation</li>
<li><a href="https://www.apache.org/foundation">About the Foundation</a></li>
<li><a href="https://projects.apache.org">The projects</a></li>
<li><a href="https://people.apache.org">The people</a></li>
<li><a href="https://www.apache.org/foundation/how-it-works.html">How we work</a></li>
<li><a href="https://www.apache.org/foundation/how-it-works.html#history">Our history</a></li>
<li><a href="https://blogs.apache.org/foundation/">News</a></li>
<li class="nav-header">Contribute</li>
<li><a href="https://www.apache.org/foundation/getinvolved.html">Get Involved</a></li>
<li class="nav-header">Committer Info</li>
<li><a href="https://www.apache.org/dev/committers.html">ASF Committers&apos; FAQ</a></li>
<li><a href="https://www.apache.org/dev/new-committers-guide.html">New Committers Guide</a></li>
<li><a href="https://gitbox.apache.org/repos/asf/creadur-site/blob/asf-site/README.md">How to publish this site</a></li>
<li><a href="https://community.apache.org/">Community</a></li>
<li><a href="https://www.apache.org/legal/">Legal</a></li>
<li><a href="https://www.apache.org/foundation/marks/">Branding</a></li>
<li><a href="https://www.apache.org/press/">Media Relations</a></li>
</ul>
</nav>
<div class="well sidebar-nav">
<div id="poweredBy">
<div class="clear"></div>
<div class="clear"></div>
<a href="https://maven.apache.org/" class="builtBy"><img class="builtBy" src="https://maven.apache.org/images/logos/maven-feather.png" /> Maven</a>
</div>
</div>
</header>
<main id="bodyColumn" class="span10">
<p>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 <a class="externalLink" href="https://creadur.apache.org">Apache Creadur</a>&#8482;, including <a class="externalLink" href="https://creadur.apache.org/whisker">Apache Whisker</a>&#8482; which audits and generates legal (for example <code>LICENSE</code>) documents for complex software distributions.</p>
<p>There are several things to keep in mind when running RAT</p>
<ol style="list-style-type: decimal;">
<li>RAT highlights possible issues.</li>
<li>RAT reports require interpretation.</li>
<li>RAT often requires some tuning before it runs well against a project.</li>
<li>RAT relies on heuristics: it may miss issues</li></ol><section><a id="Apache_RAT_Ant_Task_Library"></a>
<h1>Apache RAT Ant Task Library</h1>
<p>The RAT Ant Task Library provides a single Ant task and supporting Ant types and properties to run RAT from inside <a class="externalLink" href="https://ant.apache.org/">Apache Ant</a>.</p>
<p>Using Ant's resource abstraction the task can be used to check files on disk as well as tarballs or even URLs directly.</p><section><a id="Requirements"></a>
<h2>Requirements</h2>
<p>The RAT Ant Task Library requires Apache Ant 1.7.1 or higher (it works well with 1.8.x), Apache RAT core and transitively all dependencies of Apache RAT core.</p>
<p>In order to use the tasks Java 5 is required as of RAT 0.9 - RAT 0.8 and earlier require Java 1.4.</p>
<p>Java 8 is required for RAT 0.14 and above.</p></section><section><a id="Installation"></a>
<h2>Installation</h2>
<p>There are several ways to use the Antlib:</p>
<ul>
<li>The traditional way:
<pre class="prettyprint"><code>&lt;taskdef
resource=&quot;org/apache/rat/anttasks/antlib.xml&quot;&gt;
&lt;classpath&gt;
&lt;pathelement location=&quot;YOUR-PATH-TO/apache-rat-0.17-SNAPSHOT.jar&quot;/&gt;
&lt;/classpath&gt;
&lt;/taskdef&gt;</code></pre>
<p>With this you can use the report task like plain Ant tasks, they'll live in the default namespace. For example if you can run <code>exec</code> without any namespace prefix, you can do so for <code>report</code> as well.</p></li>
<li>Similar, but assigning a namespace URI
<pre class="prettyprint"><code>&lt;taskdef
uri=&quot;antlib:org.apache.rat.anttasks&quot;
resource=&quot;org/apache/rat/anttasks/antlib.xml&quot;&gt;
&lt;classpath&gt;
&lt;pathelement location=&quot;YOUR-PATH-TO/apache-rat-0.17-SNAPSHOT.jar&quot;/&gt;
&lt;/classpath&gt;
&lt;/taskdef&gt;</code></pre>
<p>This puts your task into a separate namespace than Ant's namespace. You would use the tasks like</p>
<pre class="prettyprint"><code>&lt;project
xmlns:rat=&quot;antlib:org.apache.rat.anttasks&quot;
xmlns=&quot;antlib:org.apache.tools.ant&quot;&gt;
...
&lt;rat:report&gt;
&lt;fileset dir=&quot;src&quot;/&gt;
&lt;/rat:report&gt;
...
&lt;/project&gt;</code></pre>
<p>or a variation thereof.</p></li>
<li>Using Ant's autodiscovery. Place <code>apache-rat-tasks.jar</code> and all dependencies into a directory and use <code>ant -lib DIR-CONTAINING-THE-JAR</code> or copy it into <code>ANT_HOME/lib</code> - and then in your build file, simply declare the namespace on the <code>project</code> tag:
<pre class="prettyprint"><code>&lt;project
xmlns:rat=&quot;antlib:org.apache.rat.anttasks&quot;
xmlns=&quot;antlib:org.apache.tools.ant&quot;&gt;</code></pre>
<p>and all tasks of this library will automatically be available in the <code>rat</code> namespace without any <code>taskdef</code>.</p></li></ul></section></section><section><a id="Adding_license_headers"></a>
<h1>Adding license headers</h1>
<p>RAT can be used to automatically add Apache-2.0 license headers to files that do not currently have them. Only files that are not excluded by the RAT configurations will be affected.</p>
<p>To add license headers use a command such as:</p>
<pre class="prettyprint"><code>&lt;project
xmlns:rat=&quot;antlib:org.apache.rat.anttasks&quot;
xmlns=&quot;antlib:org.apache.tools.ant&quot;&gt;
...
&lt;rat:report editLicense=&quot;y&quot; editCopyright=&quot;Copyright 2008 Foo&quot; editOverwrite=&quot;Y&quot;&gt;
&lt;fileset dir=&quot;path/to/source&quot;/&gt;
&lt;/rat:report&gt;
...
&lt;/project&gt;</code></pre>
<p>This command will add the license header directly to the source files along with the copyright notice. If you prefer to see which files will be changed and how, then remove the &quot;editOverwrite &quot; attribute.</p></section><section><a id="Excluding_files_from_consideration"></a>
<h1>Excluding files from consideration</h1>
<p>By default RAT Ant task includes all the files listed in an enclosed <code>fileset</code>. To exclude specific files within the set use one or more of the exclusion options. RAT uses a <a href="../apache-rat/exclusion_expression.html">modified glob exclusion</a> similar to Ant or Git.</p>
<p>RAT supports exclusion and inclusion. By default all files are processed. Using the exclude command files can be excluded from processing. In addition a file may be explicitly included. <b>Files that are explicitly included can not be excluded.</b></p><section><a id="Exclusion_by_glob_pattern"></a>
<h2>Exclusion by glob pattern</h2>
<p>The following command will exclude all files with a &quot;foo&quot; extension as well as all files in the junk folder at the root of the project.</p>
<pre class="prettyprint"><code>&lt;project
xmlns:rat=&quot;antlib:org.apache.rat.anttasks&quot;
xmlns=&quot;antlib:org.apache.tools.ant&quot;&gt;
...
&lt;rat:report&gt;
&lt;inputExclude&gt;
&lt;expr&gt;**/*.foo&lt;/expr&gt;
&lt;expr&gt;junk/**&lt;/expr&gt;
&lt;/inputExclude&gt;
&lt;fileset dir=&quot;path/to/source&quot;/&gt;
&lt;/rat:report&gt;
...
&lt;/project&gt;</code></pre></section><section><a id="Exclusion_by_glob_pattern_file"></a>
<h2>Exclusion by glob pattern file</h2>
<p>It is often more efficient to place the exclusion patterns in a file and read that from disk. The following is an example of how to do that.</p>
<pre class="prettyprint"><code>&lt;project
xmlns:rat=&quot;antlib:org.apache.rat.anttasks&quot;
xmlns=&quot;antlib:org.apache.tools.ant&quot;&gt;
...
&lt;rat:report&gt;
&lt;inputExcludeFile&gt;
&lt;file file=&quot;/tmp/junit-5065932240072873529/excludeFile.xml&quot; /&gt;
&lt;/inputExclude&gt;
&lt;fileset dir=&quot;path/to/source&quot;/&gt;
&lt;/rat:report&gt;
...
&lt;/project&gt;</code></pre></section><section><a id="Using_standard_exclusions"></a>
<h2>Using standard exclusions</h2>
<p>RAT defines a number of <a href="../apache-rat/standard_collections">standard collections</a> that can be used to exclude files based on a standard pattern. For example to exclude all the files associated with the Git SCM</p>
<pre class="prettyprint"><code>&lt;project
xmlns:rat=&quot;antlib:org.apache.rat.anttasks&quot;
xmlns=&quot;antlib:org.apache.tools.ant&quot;&gt;
...
&lt;rat:report&gt;
&lt;inputExcludeStd&gt;
&lt;std&gt;GIT&lt;/std&gt;
&lt;/inputExcludeStd&gt;
&lt;fileset dir=&quot;path/to/source&quot;/&gt;
&lt;/rat:report&gt;
...
&lt;/project&gt;</code></pre>
<p>To exclude the files specified in the <code>.gitignore</code> files the <code>inputExcludeParsedScm</code> element is used.</p>
<pre class="prettyprint"><code>&lt;project
xmlns:rat=&quot;antlib:org.apache.rat.anttasks&quot;
xmlns=&quot;antlib:org.apache.tools.ant&quot;&gt;
...
&lt;rat:report&gt;
&lt;inputExcludeStd&gt;
&lt;std&gt;GIT&lt;/std&gt;
&lt;/inputExcludeStd&gt;
&lt;inputExcludeParsedScm&gt;
&lt;std&gt;GIT&lt;/std&gt;
&lt;/inputExcludeParsedScm&gt;
&lt;fileset dir=&quot;path/to/source&quot;/&gt;
&lt;/rat:report&gt;
...
&lt;/project&gt;</code></pre>
<p>RAT will by default include all the files in hidden directories. To exclude the hidden files and directories and the git excluded resources the following command could be used:</p>
<pre class="prettyprint"><code>&lt;project
xmlns:rat=&quot;antlib:org.apache.rat.anttasks&quot;
xmlns=&quot;antlib:org.apache.tools.ant&quot;&gt;
...
&lt;rat:report&gt;
&lt;inputExcludeStd&gt;
&lt;std&gt;GIT&lt;/std&gt;
&lt;std&gt;HIDDEN_FILE&lt;/std&gt;
&lt;std&gt;HIDDEN_DIR&lt;/std&gt;
&lt;/inputExcludeStd&gt;
&lt;inputExcludeParsedScm&gt;
&lt;std&gt;GIT&lt;/std&gt;
&lt;/inputExcludeParsedScm&gt;
&lt;fileset dir=&quot;path/to/source&quot;/&gt;
&lt;/rat:report&gt;
...
&lt;/project&gt;</code></pre></section><section><a id="Excluding_files_by_size"></a>
<h2>Excluding files by size</h2>
<p>RAT will exclude files below a specified size if desired. This is done with the <code>inputExcludeSize</code> attribute. This attribute takes the the file size in bytes as an argument. The following will exclude files of 10 bytes or less.</p>
<pre class="prettyprint"><code>&lt;project
xmlns:rat=&quot;antlib:org.apache.rat.anttasks&quot;
xmlns=&quot;antlib:org.apache.tools.ant&quot;&gt;
...
&lt;rat:report inputExcludeSize=&quot;10&quot;&gt;
&lt;fileset dir=&quot;path/to/source&quot;/&gt;
&lt;/rat:report&gt;
...
&lt;/project&gt;</code></pre></section><section><a id="Including_excluded_files"></a>
<h2>Including excluded files</h2>
<p>The <code>inputExclude</code>, <code>inputExcludeFile</code> and <code>inputExcludeStd&gt; have include counterparts &lt;&lt;&lt;inputInclude</code>, <b>inputIncludeFile</b>&gt;, <code>inputIncludeStd</code>. The include options will add files back to the processing list. For example, taking the earlier &quot;<i>inputExclude</i>&quot; example, if there was a file named &quot;master/kung.foo&quot; that should not be excluded the following command will ensure that it is processed.</p>
<pre class="prettyprint"><code>&lt;project
xmlns:rat=&quot;antlib:org.apache.rat.anttasks&quot;
xmlns=&quot;antlib:org.apache.tools.ant&quot;&gt;
...
&lt;rat:report&gt;
&lt;inputExclude&gt;
&lt;expr&gt;**/*.foo&lt;/expr&gt;
&lt;expr&gt;junk/**&lt;/expr&gt;
&lt;/inputExclude&gt;
&lt;inputInclude&gt;
&lt;expr&gt;master/kung.foo&lt;/expr&gt;
&lt;/inputInclude&gt;
&lt;fileset dir=&quot;path/to/source&quot;/&gt;
&lt;/rat:report&gt;
...
&lt;/project&gt;</code></pre>
<p>The order of the arguments is not important, the <b>inputInclude</b>&gt; could have come before the <code>inputExclude</code>.</p></section></section><section><a id="Styling_output"></a>
<h1>Styling output</h1>
<p>RAT allows you to style the output as you see fit. Several stylesheets are included in the RAT package.</p>
<ul>
<li><a class="externalLink" href="https://gitbox.apache.org/repos/asf/creadur-rat/blob/master/apache-rat-core/src/main/resources/org/apache/rat/missing-headers.xsl">missing-headers</a> - Produces a report of files that are missing headers.</li>
<li><a class="externalLink" href="https://gitbox.apache.org/repos/asf/creadur-rat/blob/master/apache-rat-core/src/main/resources/org/apache/rat/plain-rat.xsl">plain-rat</a> - The default style.</li>
<li><a class="externalLink" href="https://gitbox.apache.org/repos/asf/creadur-rat/blob/master/apache-rat-core/src/main/resources/org/apache/rat/unapproved-licenses.xsl">unapproved-licenses</a> - Produces a report of the files with unapproved licenses.</li>
<li><a class="externalLink" href="https://gitbox.apache.org/repos/asf/creadur-rat/blob/master/apache-rat-core/src/main/resources/org/apache/rat/xml.xsl">xml</a> - Produces output in pretty-printed XML.
<p>These stylesheets can be specified using the <code>outputStyle</code> attribute. The following example creates a pretty printed xml report output.</p>
<pre class="prettyprint"><code>&lt;project
xmlns:rat=&quot;antlib:org.apache.rat.anttasks&quot;
xmlns=&quot;antlib:org.apache.tools.ant&quot;&gt;
...
&lt;rat:report outputStyle=&quot;xml&quot;&gt;
&lt;fileset dir=&quot;path/to/source&quot;/&gt;
&lt;/rat:report&gt;
...
&lt;/project&gt;</code></pre>
<p>To develop your own stylesheets see the RAT Output section of the menu on the left.</p></li></ul></section> </main>
</div>
</div>
<hr/>
<footer>
<div class="container-fluid">
<div class="row-fluid">
Copyright &copy; 2016-2025 The Apache Software Foundation, Licensed under the Apache License, Version 2.0.
Apache Creadur, Creadur, Apache RAT, Apache Tentacles, Apache Whisker, Apache and the ASF logo are trademarks
of The Apache Software Foundation.
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
All other marks mentioned may be trademarks or registered trademarks of their respective owners.
</div>
</div>
</footer>
</body>
</html>