| <!DOCTYPE html> |
| <!-- |
| | Generated by Apache Maven Doxia Site Renderer 1.11.1 from src/site/apt/examples/custom-license.apt.vm at 2024-05-07 |
| |
| | 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™ Plugin for Apache Maven – Custom License Matchers</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-07</span> |
| | <span id="projectVersion">Version: 0.17-SNAPSHOT</span> |
| | <a href="https://www.apache.org/" class="externalLink" title="Apache">Apache</a> > |
| <a href="https://creadur.apache.org/" class="externalLink" title="Creadur">Creadur</a> > |
| <a href="https://creadur.apache.org/rat/" class="externalLink" title="Rat">Rat</a> > |
| <a href="../index.html" title="Apache Rat™ Plugin for Apache Maven">Apache Rat™ Plugin for Apache Maven</a> > |
| Custom License Matchers |
| </div> |
| <div class="xright"> </div> |
| <div class="clear"> |
| <hr/> |
| </div> |
| </div> |
| <div id="leftColumn"> |
| <div id="navcolumn"> |
| <h5>Parent Project</h5> |
| <ul> |
| <li class="none"><a href="../../index.html" title="Apache Creadur Rat">Apache Creadur Rat</a></li> |
| </ul> |
| <h5>Overview</h5> |
| <ul> |
| <li class="none"><a href="../index.html" title="Introduction">Introduction</a></li> |
| <li class="none"><a href="../plugin-info.html" title="Goals">Goals</a></li> |
| <li class="none"><a href="../usage.html" title="Usage">Usage</a></li> |
| <li class="none"><a href="../faq.html" title="FAQ">FAQ</a></li> |
| </ul> |
| <h5>Examples</h5> |
| <ul> |
| <li class="none"><a href="../examples/basic.html" title="Basic use">Basic use</a></li> |
| <li class="none"><a href="../examples/verify.html" title="Running the plugin automatically">Running the plugin automatically</a></li> |
| <li class="none"><a href="../examples/site.html" title="Adding a report to the site">Adding a report to the site</a></li> |
| <li class="none"><strong>Custom license</strong></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> |
| <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> |
| <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="Custom_License_Matchers"></a>Custom License Matchers</h2> |
| <p>Rat comes with a set of predefined license matchers, that can be used on typical licenses. However, they will not always be sufficient. In such cases, you may configure a custom license matcher.</p> |
| <p>The simplest way to create a license check is to create an XML file describing the new license and add it to the processing with the additionalLicenseFiles option.</p> |
| <p>The second option is to define the custom license directly in the POM. Unlike earlier version (before 0.16) no custom implementations are required to define custom licenses.</p> |
| <p>There is a file that defines all of the standard licenses: <a class="externalLink" href="https://github.com/apache/creadur-rat/blob/master/apache-rat-core/src/main/resources/org/apache/rat/default.xml">default.xml</a></p> |
| <p>Please be aware that custom licenses need to have <b>unique names</b>, otherwise a warning is issued and your custom definitions are ignored in favour of the standard license definitions.</p> |
| <div> |
| <pre> /** |
| * Yet Another Software License, 1.0 |
| * |
| * Lots of text, specifying the users rights, and whatever ... |
| */</pre></div> |
| <p>A very easy way to search for such headers would be to scan for the string "Yet Another Software License, 1.0". And here's how you would do that in your POM:</p> |
| <div> |
| <pre> <build> |
| <plugins> |
| ... |
| <plugin> |
| <groupId>org.apache.rat</groupId> |
| <artifactId>apache-rat-plugin</artifactId> |
| <version>0.17-SNAPSHOT</version> |
| <configuration> |
| <licenses> |
| <license> |
| <family>YASL1</family> |
| <notes></notes> |
| <text>Yet Another Software License, 1.0</text> |
| </license> |
| </licenses> |
| <families> |
| <family> |
| <id>YASL1</id> |
| <name>Yet Another Software License</name> |
| </family> |
| </families> |
| </configuration> |
| </plugin> |
| ... |
| </plugins> |
| </build></pre></div> |
| <p>This is very similar to the XML format for defining the configuration.</p></section><section> |
| <h2><a name="Approved_License_Families"></a>Approved License Families</h2> |
| <p>By default all POM defined licenses are considered approved, this is a change from pre 0.16 versions. If there are families that are defined in the pom but that should not be considered approved then a list of approved license families must be provided.</p> |
| <p>In the following example, we define YASL1 and BAD1 and then indicate that BAD1 is bad by specifying that YASL1 is good.</p> |
| <div> |
| <pre> <build> |
| <plugins> |
| ... |
| <plugin> |
| <groupId>org.apache.rat</groupId> |
| <artifactId>apache-rat-plugin</artifactId> |
| <version>0.17-SNAPSHOT</version> |
| <configuration> |
| <licenses> |
| <license> |
| <family>YASL1</family> |
| <notes></notes> |
| <text>Yet Another Software License, 1.0</text> |
| </license> |
| </licenses> |
| <families> |
| <family> |
| <id>YASL1</id> |
| <name>Yet Another Software License</name> |
| </family> |
| <family> |
| <id>BAD1</id> |
| <name>A Bad Sofware License</name> |
| </family> |
| </families> |
| <approvedLicenses> |
| <id>YASL1</id> |
| </approvedLicenses> |
| </configuration> |
| </plugin> |
| ... |
| </plugins> |
| </build></pre></div></section><section> |
| <h2><a name="Overview_of_configuration_options"></a>Overview of configuration options</h2> |
| <p>When defining custom licenses, remember the following architecture constraints:</p> |
| <ul> |
| <li>Each license is associated with a family. Multiple licenses can be associated with a family.</li> |
| <li>Each license may have a notes element.</li> |
| <li>Each license has one matcher.</li></ul><section> |
| <h3><a name="Matcher_details"></a>Matcher details</h3> |
| <p><b>all</b> - A collection of matchers in which all enclosed matchers have to be true for the matcher to report true.</p> |
| <div> |
| <pre><all> |
| <text>This text is required</text> |
| <text>as is this text, both have to trigger before 'all' will be true</text> |
| </all></pre></div> |
| <p><b>any</b> - A collection of matchers that will report true if any enclosed matcher is true.</p> |
| <div> |
| <pre><any> |
| <text>This text will trigger a match all by itself</text> |
| <text>So will this text.</text> |
| </any></pre></div> |
| <p><b>copyright</b> - A matcher that matches Copyright text. This uses regular expressions and so should only be used when looking for copyrights with specific patterns that are not caught by a standard text matcher. This matcher will match <code>"(C)"</code>, <code>"copyright"</code>, or <code>"©"</code>. (text is not case sensitive). It will also match things like <code>Copyright (c) joe 1995</code> as well as <code>Copyright (C) 1995 joe</code> and <code>Copyright (C) joe 1995</code>. Copyright has 3 child elements:</p> |
| <ul> |
| <li><b>start</b> - the starting date of the copyright or the only date.</li> |
| <li><b>end</b> - the ending date of the copyright. Only valid if the starting date is provided.</li> |
| <li><b>owner</b> - the copyright owner. |
| <div> |
| <pre> |
| <copyright> <!-- this will match (c) 1995-1996 joe, or (c) joe 1995-1996 --> |
| <start>1995</text> |
| <end>1996</end> |
| <owner>joe</owner> |
| </copyright> |
| |
| <copyright> <!-- this will match (c) 1995 joe, or (c) joe 1995 --> |
| <start>1995</text> |
| <owner>joe</owner> |
| </copyright> |
| |
| <copyright> <!-- this will match (c) nnnn joe, or (c) joe nnnn, where nnnn is a 4 digit year --> |
| <owner>joe</owner> |
| </copyright> |
| |
| <copyright> <!-- this will match (c) nnnn, where nnnn is a 4 digit year --> |
| </copyright> |
| </pre></div></li></ul> |
| <p><b>not</b> - A matcher that wraps one matcher and negates its value. Not matchers require that the entire header be read before it can report true or false. This may significantly slow processing.</p> |
| <div> |
| <pre><not> |
| <text>This text must not be present</text> |
| </not></pre></div> |
| <p><b>regex</b> - A matcher that matches a regex string.</p> |
| <div> |
| <pre><regex>[H|h]ello\s[W|w]orld</regex></pre></div> |
| <p><b>spdx</b> - A matcher that matches SPDX tags. SPDX tags have the form: <code>SPDX-License-Identifier: short-name</code>, where short-name matches the regex pattern <code>"[A-Za-z0-9\.-]+".</code> spdx takes the short name as an argument.</p> |
| <div> |
| <pre><spdx>Apache-2.0</spdx></pre></div><section> |
| <h4><a name="Combining_the_examples_together"></a>Combining the examples together</h4> |
| <div> |
| <pre><all> |
| <any> <!-- HINT: any of the enclosed matchers will cause a match --> |
| <all> <!-- must have both 'This text is required' and a copyright statement --> |
| <text>This text is required</text> |
| <copyright /> |
| </all> |
| <copyright> <!-- accept any file that has a copyright by joe --> |
| <owner>joe</owner> |
| </copyright> |
| <!-- accept any file with "Hello World" --> |
| <regex>[H|h]ello\s[W|w]orld</regex> |
| <!-- accept any file with 'SPDX-License-Identifier: Apache-2.0' --> |
| <spdx>Apache-2.0</spdx> |
| </any> |
| <!-- make sure the text 'This text must not be present' is not present --> |
| <not> |
| <text>This text must not be present</text> |
| </not> |
| </all></pre></div></section></section></section> |
| </div> |
| </div> |
| <div class="clear"> |
| <hr/> |
| </div> |
| <div id="footer"> |
| <div class="xright"> |
| Copyright © 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> |