This is an automated email from the ASF dual-hosted git repository.

claude pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/creadur-rat.git


The following commit(s) were added to refs/heads/master by this push:
     new 688f342e RAT-524: fix document name.is case sensitive detection time 
and exclude Maven excludes by default during Maven plugin runs (#598)
688f342e is described below

commit 688f342e6c0514e9e2a64b113f1465af07dad792
Author: Claude Warren <[email protected]>
AuthorDate: Sat Dec 20 17:07:46 2025 +0100

    RAT-524: fix document name.is case sensitive detection time and exclude 
Maven excludes by default during Maven plugin runs (#598)
    
    * Moved FSInfo data into separate object and cached it in a REGISTRY map
    
    * added skipping of MAVEN files when running under Maven
    
    ---------
    
    Co-authored-by: P. Ottlinger <[email protected]>
---
 .../java/org/apache/rat/document/DocumentName.java | 113 ++++++++++++++-------
 .../src/it/RAT-524/invoker.properties              |  16 +++
 apache-rat-plugin/src/it/RAT-524/pom.xml           |  63 ++++++++++++
 apache-rat-plugin/src/it/RAT-524/verify.groovy     |  37 +++++++
 .../java/org/apache/rat/mp/AbstractRatMojo.java    |   2 +-
 .../main/java/org/apache/rat/mp/RatCheckMojo.java  |  20 ++++
 .../src/templates/apt/mvn_options.apt.vm           |   4 +
 src/changes/changes.xml                            |   3 +
 8 files changed, 221 insertions(+), 37 deletions(-)

diff --git 
a/apache-rat-core/src/main/java/org/apache/rat/document/DocumentName.java 
b/apache-rat-core/src/main/java/org/apache/rat/document/DocumentName.java
index dfe6d057..c2c0510e 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/document/DocumentName.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/document/DocumentName.java
@@ -28,8 +28,10 @@ import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.stream.Collectors;
 
 import org.apache.commons.lang3.StringUtils;
@@ -298,43 +300,36 @@ public class DocumentName implements 
Comparable<DocumentName> {
         return HashCodeBuilder.reflectionHashCode(this);
     }
 
-    /**
-     * The file system information needed to process document names.
-     */
-    public static class FSInfo implements Comparable<FSInfo> {
-        /** The common name for the file system this Info represents. */
-        private final String name;
-        /** The separator between directory names. */
-        private final String separator;
-        /** The case-sensitivity flag. */
+    private static final class FSInfoData {
+        /** The case sensitivity flag */
         private final boolean isCaseSensitive;
         /** The list of roots for the file system. */
         private final List<String> roots;
+        /** The separator between directory names. */
+        private final String separator;
 
-        public static FSInfo getDefault() {
-            FSInfo result = (FSInfo) System.getProperties().get("FSInfo");
-            return result == null ?
-                    new FSInfo("default", FileSystems.getDefault())
-                    : result;
-        }
         /**
-         * Constructor. Extracts the necessary data from the file system.
-         * @param fileSystem the file system to extract data from.
+         * Constructor for known properties.
+         * @param separator the directory separator character(s).
+         * @param isCaseSensitive {@code true} if the file system is cases 
sensitive.
+         * @param roots THe list of roots for the file system.
          */
-        public FSInfo(final FileSystem fileSystem) {
-            this("anon", fileSystem);
+        FSInfoData(final String separator, final boolean isCaseSensitive, 
final List<String> roots) {
+            this.isCaseSensitive = isCaseSensitive;
+            this.roots = roots;
+            this.separator = separator;
         }
 
         /**
-         * Constructor. Extracts the necessary data from the file system.
-         * @param fileSystem the file system to extract data from.
+         * Constructor for an arbitrary file system.
+         * This constructor can be processor intensive as it has to check the 
file system for case sensitivity.
+         * @param fileSystem the file system.
          */
-        public FSInfo(final String name, final FileSystem fileSystem) {
-            this.name = name;
-            this.separator = fileSystem.getSeparator();
-            this.isCaseSensitive = isCaseSensitive(fileSystem);
+        FSInfoData(final FileSystem fileSystem) {
+            isCaseSensitive = isCaseSensitive(fileSystem);
             roots = new ArrayList<>();
             fileSystem.getRootDirectories().forEach(r -> 
roots.add(r.toString()));
+            separator = fileSystem.getSeparator();
         }
 
         /**
@@ -375,26 +370,72 @@ public class DocumentName implements 
Comparable<DocumentName> {
             return isCaseSensitive;
         }
 
+    }
+    /**
+     * The file system information needed to process document names.
+     */
+    public static final class FSInfo implements Comparable<FSInfo> {
         /**
-         * Gets the common name for the underlying file system.
-         * @return the common file system name.
+         * The map of FileSystem to FSInfoData used to avoid expensive 
FileSystem processing.
          */
-        @Override
-        public String toString() {
-            return name;
+        private static final Map<FileSystem, FSInfoData> REGISTRY = new 
ConcurrentHashMap<>();
+
+        /** The case-sensitivity flag. */
+        private final FSInfoData data;
+
+        /** The common name for the file system */
+        private final String name;
+
+        /**
+         * Gets the FSInfo for the default file system.
+         * If the System property {@code FSInfo} is set, the {@code FSInfo} 
stored there is used, otherwise
+         * the {@link FileSystem} returned from {@link 
FileSystems#getDefault()} is used.
+         * @return the FSInfo for the default file system.
+         */
+        public static FSInfo getDefault() {
+            FSInfo result = (FSInfo) System.getProperties().get("FSInfo");
+            return result == null ?
+                    new FSInfo(FileSystems.getDefault())
+                    : result;
+        }
+
+        /**
+         * Constructor. Extracts the necessary data from the file system.
+         * @param fileSystem the file system to extract data from.
+         */
+        public FSInfo(final FileSystem fileSystem) {
+            this("anon", fileSystem);
+        }
+
+        /**
+         * Constructor. Extracts the necessary data from the file system.
+         * @param name the common name for the file system.
+         * @param fileSystem the file system to extract data from.
+         */
+        FSInfo(final String name, final FileSystem fileSystem) {
+            this.data = REGISTRY.computeIfAbsent(fileSystem, k -> new 
FSInfoData(fileSystem));
+            this.name = name;
         }
 
         /**
          * Constructor for virtual/abstract file systems for example the entry 
names within an archive.
+         * @param name the common name for the file system.
          * @param separator the separator string to use.
          * @param isCaseSensitive the case-sensitivity flag.
          * @param roots the roots for the file system.
          */
         FSInfo(final String name, final String separator, final boolean 
isCaseSensitive, final List<String> roots) {
+            data = new FSInfoData(separator, isCaseSensitive, roots);
             this.name = name;
-            this.separator = separator;
-            this.isCaseSensitive = isCaseSensitive;
-            this.roots = new ArrayList<>(roots);
+        }
+
+        /**
+         * Gets the common name for the underlying file system.
+         * @return the common file system name.
+         */
+        @Override
+        public String toString() {
+            return name;
         }
 
         /**
@@ -402,7 +443,7 @@ public class DocumentName implements 
Comparable<DocumentName> {
          * @return The directory separator.
          */
         public String dirSeparator() {
-            return separator;
+            return data.separator;
         }
 
         /**
@@ -410,7 +451,7 @@ public class DocumentName implements 
Comparable<DocumentName> {
          * @return the case-sensitivity flag.
          */
         public boolean isCaseSensitive() {
-            return isCaseSensitive;
+            return data.isCaseSensitive;
         }
 
         /**
@@ -419,7 +460,7 @@ public class DocumentName implements 
Comparable<DocumentName> {
          * @return an optional containing the root or empty.
          */
         public Optional<String> rootFor(final String name) {
-            for (String sysRoot : roots) {
+            for (String sysRoot : data.roots) {
                 if (name.startsWith(sysRoot)) {
                     return Optional.of(sysRoot);
                 }
diff --git a/apache-rat-plugin/src/it/RAT-524/invoker.properties 
b/apache-rat-plugin/src/it/RAT-524/invoker.properties
new file mode 100644
index 00000000..1c089b46
--- /dev/null
+++ b/apache-rat-plugin/src/it/RAT-524/invoker.properties
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+invoker.goals = clean -X apache-rat:rat
diff --git a/apache-rat-plugin/src/it/RAT-524/pom.xml 
b/apache-rat-plugin/src/it/RAT-524/pom.xml
new file mode 100644
index 00000000..b759b439
--- /dev/null
+++ b/apache-rat-plugin/src/it/RAT-524/pom.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    RAT-524 integration test
+    Copyright (C) 2025, ASF Apache Creadur
+
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.rat.test</groupId>
+  <artifactId>it-rat524</artifactId>
+  <version>1.0</version>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.rat</groupId>
+        <artifactId>apache-rat-plugin</artifactId>
+        <version>@pom.version@</version>
+        <configuration>
+          <verbose>true</verbose>
+          <consoleOutput>true</consoleOutput>
+          <ignoreErrors>false</ignoreErrors>
+          <inputIncludes>
+            <include>pom.xml</include>
+          </inputIncludes>
+        </configuration>
+      </plugin>
+    </plugins>
+    <!-- RAT-354: prevent warning about missing version property of 
maven-clean-plugin -->
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-clean-plugin</artifactId>
+          <version>3.5.0</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.rat</groupId>
+        <artifactId>apache-rat-plugin</artifactId>
+        <version>@pom.version@</version>
+      </plugin>
+    </plugins>
+  </reporting>
+</project>
diff --git a/apache-rat-plugin/src/it/RAT-524/verify.groovy 
b/apache-rat-plugin/src/it/RAT-524/verify.groovy
new file mode 100644
index 00000000..51b03a62
--- /dev/null
+++ b/apache-rat-plugin/src/it/RAT-524/verify.groovy
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import org.apache.rat.testhelpers.TextUtils
+
+content = new File(basedir, 'build.log').text
+
+// verify debug output
+assert content.contains('BUILD SUCCESS')
+assert ! content.contains('[WARNING] No resources included')
+assert content.contains('Adding [MAVEN] to input-exclude-std')
+assert content.contains('Excluding MAVEN collection.')
+
+// Report is in apache-rat-plugin/target/invoker-reports
+// Make sure that report is generated completely
+report = new File(basedir, 'target/site/rat-report.html').text
+assert TextUtils.isMatching("^  /verify.groovy\\s+S ", report)
+assert TextUtils.isMatching("^  /pom.xml\\s+S ", report)
+assert TextUtils.isMatching("^  
/target\\s+I\\s+application/octet-stream\\s+\\(directory\\)", report)
+
+assert report.contains('Unapproved:         0')
+assert report.contains('Apache License 2.0: 3')
+assert report.contains('IGNORED: 3') // MAVEN excludes
+assert report.contains('STANDARD: 3')
diff --git 
a/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java 
b/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java
index 6624022e..ab2129c9 100644
--- a/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java
+++ b/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java
@@ -70,7 +70,7 @@ public abstract class AbstractRatMojo extends BaseRatMojo {
      * The base directory, in which to search for files.
      */
     @Parameter(property = "rat.basedir", defaultValue = "${basedir}", required 
= true)
-    private File basedir;
+    protected File basedir;
 
     /**
      * Specifies the verbose output.
diff --git 
a/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java 
b/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java
index 6fabeb60..63b98aa5 100644
--- a/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java
+++ b/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java
@@ -20,6 +20,7 @@ package org.apache.rat.mp;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.FileFilter;
 import java.io.IOException;
 import java.io.Writer;
 import java.nio.charset.StandardCharsets;
@@ -34,6 +35,7 @@ import org.apache.rat.ReportConfiguration;
 import org.apache.rat.Reporter;
 import org.apache.rat.commandline.Arg;
 import org.apache.rat.commandline.StyleSheets;
+import org.apache.rat.config.exclusion.StandardCollection;
 import org.apache.rat.license.LicenseSetFactory.LicenseFilter;
 import org.apache.rat.report.claim.ClaimStatistic;
 import org.apache.rat.utils.DefaultLog;
@@ -57,6 +59,12 @@ public class RatCheckMojo extends AbstractRatMojo {
     @Parameter(defaultValue = "${project.build.directory}/rat.txt")
     private File defaultReportFile;
 
+    /**
+     * The defined build directory
+     */
+    @Parameter(defaultValue = "${project.build.directory}", readonly = true)
+    private String buildDirectory;
+
     /**
      * Where to store the report.
      * @deprecated Use 'out' property instead.
@@ -159,6 +167,18 @@ public class RatCheckMojo extends AbstractRatMojo {
         if (numUnapprovedLicenses > 0) {
             
result.getClaimValidator().setMax(ClaimStatistic.Counter.UNAPPROVED, 
numUnapprovedLicenses);
         }
+        result.addExcludedCollection(StandardCollection.MAVEN);
+        if (StandardCollection.MAVEN.fileProcessorBuilder().hasNext()) {
+            result.addExcludedFileProcessor(StandardCollection.MAVEN);
+        }
+        if (StandardCollection.MAVEN.hasStaticDocumentNameMatcher()) {
+            StandardCollection.MAVEN.staticDocumentNameMatcher();
+        }
+
+        String buildDirAbsolutePath = new 
File(buildDirectory).getAbsolutePath();
+        FileFilter buildFilter = f -> 
f.getAbsolutePath().startsWith(buildDirAbsolutePath);
+        result.addExcludedFilter(buildFilter);
+
         return result;
     }
 
diff --git a/apache-rat-plugin/src/templates/apt/mvn_options.apt.vm 
b/apache-rat-plugin/src/templates/apt/mvn_options.apt.vm
index 4a22a214..a127eb2c 100644
--- a/apache-rat-plugin/src/templates/apt/mvn_options.apt.vm
+++ b/apache-rat-plugin/src/templates/apt/mvn_options.apt.vm
@@ -26,6 +26,10 @@ Maven Options
  The RAT Maven plugin has many of the same options as the command line as well 
as a few that are specific to the Maven
   environment. The argument types specified in the list below are defined in 
the section following.
 
+ By default the RAT Maven plugin excludes the MAVEN standard collection as 
well as the defined project build directory.
+  If there there is a need to include any of these the MAVEN standard 
collection can be added to
+  \<inputIncludeStd\> and the project build directory can be added to 
\<inputInclude\> using the standard expression syntax.
+
 * The Options
 
 #set($descEnd = ${rat.doubleLine} + " ")
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 2eb18169..c706c583 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -68,6 +68,9 @@ in order to be properly linked in site reports.
     </release>
     -->
     <release version="1.0.0" date="xxxx-yy-zz" description="Current SNAPSHOT - 
release to be done">
+      <action issue="RAT-524" type="add" dev="claudenw">
+        Fixes case-sensitive detection time of underlying file system and 
removed MAVEN StandardCollection from default Maven processing to improve 
overall processing time.
+      </action>
       <action issue="RAT-508" type="update" dev="claudenw" due-to="Gary D. 
Gregory">
         Removed excess INFO logging in Maven plugin. Run with -X or use the 
verbose option in order to see output on debug level.
       </action>  

Reply via email to