blob: 9ee8e42e691921bbc35cb0d13fcef91c99ce5279 [file] [log] [blame]
<!DOCTYPE html>
<!--
| Generated by Apache Maven Doxia Site Renderer 1.11.1 from src/site/apt/license_def.apt.vm at 2024-05-27
| Rendered using Apache Maven Default Skin
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="generator" content="Apache Maven Doxia Site Renderer 1.11.1" />
<title>Apache Rat&trade; &#x2013; How to define new licenses</title>
<link rel="stylesheet" href="./css/maven-base.css" />
<link rel="stylesheet" href="./css/maven-theme.css" />
<link rel="stylesheet" href="./css/site.css" />
<link rel="stylesheet" href="./css/print.css" media="print" />
<link href="https://creadur.apache.org/font/matesc.css" type="text/css" rel="stylesheet" />
</head>
<body class="composite">
<div id="banner">
<a href="https://www.apache.org/" id="bannerLeft"><img src="https://www.apache.org/img/asf_logo.png" alt="The Apache Software Foundation" title="The Apache Software Foundation"/></a> <div class="clear">
<hr/>
</div>
</div>
<div id="breadcrumbs">
<div class="xleft">
<span id="publishDate">Last Published: 2024-05-27</span>
| <span id="projectVersion">Version: 0.17-SNAPSHOT</span>
| <a href="https://www.apache.org/" class="externalLink" title="Apache">Apache</a> &gt;
<a href="https://creadur.apache.org/" class="externalLink" title="Creadur">Creadur</a> &gt;
<a href="https://creadur.apache.org/rat/" class="externalLink" title="Rat">Rat</a> &gt;
How to define new licenses
</div>
<div class="xright"> </div>
<div class="clear">
<hr/>
</div>
</div>
<div id="leftColumn">
<div id="navcolumn">
<h5>Apache Ratâ„¢</h5>
<ul>
<li class="none"><a href="index.html" title="Introducing Rat">Introducing Rat</a></li>
<li class="none"><a href="apidocs/index.html" title="Javadocs">Javadocs</a></li>
<li class="none"><a href="download_rat.cgi" title="Downloads">Downloads</a></li>
<li class="none"><a href="RELEASE_NOTES.txt" title="Changes">Changes</a></li>
</ul>
<h5>Running Rat</h5>
<ul>
<li class="none"><a href="apache-rat/index.html" title="From The Command Line">From The Command Line</a></li>
<li class="none"><a href="apache-rat-tasks/index.html" title="With Ant">With Ant</a></li>
<li class="none"><a href="apache-rat-plugin/index.html" title="With Maven">With Maven</a></li>
</ul>
<h5>Apache Creadurâ„¢</h5>
<ul>
<li class="none"><a href="https://creadur.apache.org" class="externalLink" title="Creadur Project Home">Creadur Project Home</a></li>
<li class="none"><a href="https://creadur.apache.org/tentacles" class="externalLink" title="Apache Tentacles">Apache Tentacles</a></li>
<li class="none"><a href="https://creadur.apache.org/whisker" class="externalLink" title="Apache Whisker">Apache Whisker</a></li>
<li class="none"><a href="https://www.apache.org/security/" class="externalLink" title="Security">Security</a></li>
<li class="none"><a href="https://www.apache.org/licenses/" class="externalLink" title="License">License</a></li>
<li class="none"><a href="https://privacy.apache.org/policies/privacy-policy-public.html" class="externalLink" title="Privacy">Privacy</a></li>
<li class="none"><a href="https://www.apache.org/foundation/sponsorship.html" class="externalLink" title="Sponsorship">Sponsorship</a></li>
<li class="none"><a href="https://www.apache.org/foundation/thanks.html" class="externalLink" title="Thanks">Thanks</a></li>
</ul>
<h5>The Apache Software Foundation</h5>
<ul>
<li class="none"><a href="https://www.apache.org/foundation" class="externalLink" title="About the Foundation">About the Foundation</a></li>
<li class="none"><a href="https://projects.apache.org" class="externalLink" title="The projects">The projects</a></li>
<li class="none"><a href="https://people.apache.org" class="externalLink" title="The people">The people</a></li>
<li class="none"><a href="https://www.apache.org/foundation/how-it-works.html" class="externalLink" title="How we work">How we work</a></li>
<li class="none"><a href="https://www.apache.org/foundation/how-it-works.html#history" class="externalLink" title="Our history">Our history</a></li>
<li class="none"><a href="https://blogs.apache.org/foundation/" class="externalLink" title="News">News</a></li>
</ul>
<h5>Contribute</h5>
<ul>
<li class="none"><a href="https://www.apache.org/foundation/getinvolved.html" class="externalLink" title="Get Involved">Get Involved</a></li>
</ul>
<h5>Committer Info</h5>
<ul>
<li class="none"><a href="https://www.apache.org/dev/committers.html" class="externalLink" title="ASF Committers' FAQ">ASF Committers' FAQ</a></li>
<li class="none"><a href="https://www.apache.org/dev/new-committers-guide.html" class="externalLink" title="New Committers Guide">New Committers Guide</a></li>
<li class="none"><a href="site-publish.html" title="Howto publish this site">Howto publish this site</a></li>
<li class="none"><a href="https://community.apache.org/" class="externalLink" title="Community">Community</a></li>
<li class="none"><a href="https://www.apache.org/legal/" class="externalLink" title="Legal">Legal</a></li>
<li class="none"><a href="https://www.apache.org/foundation/marks/" class="externalLink" title="Branding">Branding</a></li>
<li class="none"><a href="https://www.apache.org/press/" class="externalLink" title="Media Relations">Media Relations</a></li>
</ul>
<h5>Modules</h5>
<ul>
<li class="none"><a href="apache-rat-core/index.html" title="Apache Creadur Rat::Core">Apache Creadur Rat::Core</a></li>
<li class="none"><a href="apache-rat-plugin/index.html" title="Apache Creadur Rat::Plugin4Maven">Apache Creadur Rat::Plugin4Maven</a></li>
<li class="none"><a href="apache-rat-tasks/index.html" title="Apache Creadur Rat::Tasks4Ant">Apache Creadur Rat::Tasks4Ant</a></li>
<li class="none"><a href="apache-rat/index.html" title="Apache Creadur Rat::Command Line">Apache Creadur Rat::Command Line</a></li>
<li class="none"><a href="apache-rat-tools/index.html" title="Apache Creadur Rat::Tools">Apache Creadur Rat::Tools</a></li>
</ul>
<h5>Project Documentation</h5>
<ul>
<li class="collapsed"><a href="project-info.html" title="Project Information">Project Information</a></li>
<li class="collapsed"><a href="project-reports.html" title="Project Reports">Project Reports</a></li>
</ul>
<a href="https://maven.apache.org/" title="Maven" class="poweredBy">
<img class="poweredBy" alt="Maven" src="https://maven.apache.org/images/logos/maven-feather.png" />
</a>
</div>
</div>
<div id="bodyColumn">
<div id="contentBox">
<section>
<h2><a name="How_to_define_licenses_in_Apache_Rat"></a>How to define licenses in Apache Rat</h2>
<p>All licenses in Apache Rat are defined in configuration files. There is a default <a class="externalLink" href="https://gitbox.apache.org/repos/asf/creadur-rat/blob/master/apache-rat-core/src/main/resources/org/apache/rat/default.xml"> XML based configuration file</a> that can serve as a good example of various definitions.</p>
<p>It is possible to create new parsers for different configuration formats. But that task is beyond the scope of this document. In this document we will address how to define licenses in the default XML format.</p>
<p>The XML document has a root node named &quot;rat-config&quot; which comprises 4 major sections: &quot;Families&quot;, &quot;Licenses&quot;, &quot;Approved&quot; and &quot;Matchers&quot;.</p><section>
<h3><a name="Families"></a>Families</h3>
<p>Families are groups that define licenses that share similarities. Each family has an id and a name. An example of an entry in this section is</p>
<div class="source">
<pre> &lt;rat-config&gt;
&lt;families&gt;
&lt;family id=&quot;AL&quot; name=&quot;Apache License Version 2.0&quot; /&gt;
&lt;/families&gt;
&lt;/rat-config&gt;</pre></div></section><section>
<h3><a name="Matchers"></a>Matchers</h3>
<p>Matchers define tests that check the contents of files for specific patterns. Matchers are defined in Java code and are required to have Builder classes that build them. There is <a href="./matcher_def.html">additional documentation explaining how to create new Matchers</a>. In the XML document Matchers are identified by the &quot;matcher&quot; element that has a single &quot;class&quot; property. The value of the &quot;class&quot; property is the fully qualified class name that identifies a Builder class. An example of a matchers entry is</p>
<div class="source">
<pre> &lt;rat-config&gt;
&lt;matchers&gt;
&lt;matcher class=&quot;org.apache.rat.configuration.builders.AnyBuilder&quot; /&gt;
&lt;matcher class=&quot;org.apache.rat.configuration.builders.SpdxBuilder&quot; /&gt;
&lt;matcher class=&quot;org.apache.rat.configuration.builders.TextBuilder&quot; /&gt;
&lt;/matcher&gt;
&lt;/rat-config&gt;</pre></div></section><section>
<h3><a name="Licenses"></a>Licenses</h3>
<p>License elements have three properties: &quot;family&quot;, &quot;id&quot;, and &quot;name&quot;. The family property must refer to the &quot;id&quot; of a family element. The family element can be defined in the current document or in another included document. It has to exist by the time all the configuration files are read. The &quot;id&quot; element is optional, if it is not provided the id will be set to the id of the associated family. However, the &quot;id&quot; property must be unique across all licenses. The &quot;name&quot; property is also optional. If not specified the name of the associated family will be used. It is recommended that each license have a unique name as name conflicts make problem determination difficult.</p>
<p>License elements have two child element types. The first is &quot;notes&quot;. There may be multiple &quot;notes&quot; child elements. They are simple text elements that define notes about the license. The other element is a Matcher type. A matcher element is defined by a builder in the &quot;matchers&quot; section as described above. The matchers listed in the example above define the &quot;any&quot;, &quot;spdx&quot;, and &quot;text&quot; matcher elements.</p>
<p>When defining the license the matcher is required and only one may be defined. However, there are matchers that accept multiple matcher child nodes. In the example below the CDDL1 license uses the &quot;any&quot; matcher. The &quot;any&quot; matcher accepts multiple child matchers and will report a match if any of the enclosed matchers report a match. In the example below the &quot;any&quot; matcher has &quot;text&quot; and &quot;spdx&quot; child matchers. The &quot;text&quot; matcher will match the enclosed text and the &quot;spdx&quot; matcher matches <a class="externalLink" href="https://spdx.org/licenses/">SPDX</a> tags. The second license defined below is the &quot;ILLUMOS&quot; license. It shares the same family as the CDDL1 license, has its own &quot;id&quot; and &quot;name&quot; properties. It also has a &quot;note&quot; child element that tells the user that it is a modified CDDL1 license. The license has a single &quot;text&quot; matcher.</p>
<div class="source">
<pre> &lt;rat-config&gt;
&lt;licenses&gt;
&lt;license family=&quot;CDDL1&quot;&gt;
&lt;any&gt;
&lt;text&gt;The contents of this file are subject to the terms of the
Common Development and Distribution License(&quot;CDDL&quot;) (the
&quot;License&quot;). You may not use this file except in compliance
with the License.&lt;/text&gt;
&lt;spdx name='CDDL-1.0' /&gt;
&lt;/any&gt;
&lt;/license&gt;
&lt;license family=&quot;CDDL1&quot; id=&quot;ILLUMOS&quot; name=&quot;ILLUMOS CDDL1 Derived license&quot;&gt;
&lt;note&gt;Modified CDDL1 license&lt;/note&gt;
&lt;text&gt;The contents of this file are subject to the terms of
the Common Development and Distribution License (the
&quot;License&quot;) You may not use this file except in compliance
with the License. &lt;/text&gt;
&lt;/license&gt;
&lt;/licenses&gt;
&lt;/rat-config&gt;</pre></div></section><section>
<h3><a name="Approved"></a>Approved </h3>
<p>Approved element lists the approved licenses from this configuration. It is possible to define licenses that you want to detect but not allow. If the &quot;approved&quot; element is not present all defined families are considered to be approved. The approved entry has &quot;family&quot; child entries that have &quot;license_ref&quot; properties that reference the &quot;id&quot; of the family being approved.</p>
<div class="source">
<pre> &lt;rat-config&gt;
&lt;approved&gt;
&lt;family license_ref='AL' /&gt;
&lt;/approved&gt;
&lt;/rat-config&gt;</pre></div></section><section>
<h3><a name="Listing_components"></a>Listing components</h3>
<p>All the components (Licenses and Matchers) defined in the system can be displayed using the Documentation tool. Download the apache-rat-tools-0.17-SNAPSHOT.jar and run the tool execute:</p>
<div class="source">
<pre>java -cp apache-rat-0.17-SNAPSHOT.jar:apache-rat-tools-0.17-SNAPSHOT org.apache.rat.Documentation</pre></div>
<p>The tool take the same arguments as the standard Rat CLI, so additional license files can be defined. To display help for the tool execute </p>
<div class="source">
<pre>java -cp apache-rat-0.17-SNAPSHOT.jar:apache-rat-tools-0.17-SNAPSHOT org.apache.rat.Documentation --help</pre></div></section></section>
</div>
</div>
<div class="clear">
<hr/>
</div>
<div id="footer">
<div class="xright">
Copyright &copy; 2016-2024 The Apache Software Foundation, Licensed under the Apache License, Version 2.0.
Apache Creadur, Creadur, Apache Rat, Apache Tentacles, Apache Whisker, Apache and the Apache feather 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 class="clear">
<hr/>
</div>
</div>
</body>
</html>