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

pottlinger pushed a commit to branch feature/RAT-259
in repository https://gitbox.apache.org/repos/asf/creadur-rat.git

commit 63d90478429b14a5335824e222c1ebf7263d6ffe
Author: rfscholte <[email protected]>
AuthorDate: Wed May 13 22:55:11 2020 +0200

    [RAT-268] apache-rat-plugin incorrectly assumes poms module is always a 
directory
---
 apache-rat-plugin/pom.xml                          | 12 +++---
 .../src/it/RAT-268/invoker.properties              | 16 ++++++++
 apache-rat-plugin/src/it/RAT-268/module1/pom.xml   | 29 +++++++++++++
 apache-rat-plugin/src/it/RAT-268/module1/src.apt   | 12 ++++++
 .../src/it/RAT-268/module2/module2.pom             | 29 +++++++++++++
 apache-rat-plugin/src/it/RAT-268/module2/src.apt   | 12 ++++++
 apache-rat-plugin/src/it/RAT-268/module3/pom.xml   | 29 +++++++++++++
 apache-rat-plugin/src/it/RAT-268/module3/src.apt   | 12 ++++++
 apache-rat-plugin/src/it/RAT-268/pom.xml           | 48 ++++++++++++++++++++++
 .../java/org/apache/rat/mp/AbstractRatMojo.java    |  8 +++-
 10 files changed, 200 insertions(+), 7 deletions(-)

diff --git a/apache-rat-plugin/pom.xml b/apache-rat-plugin/pom.xml
index b6b59bb..594b3a1 100644
--- a/apache-rat-plugin/pom.xml
+++ b/apache-rat-plugin/pom.xml
@@ -85,7 +85,7 @@
           <configuration>
             <excludes>
               <!-- These files do not have license headers because they are 
used to test license headers -->
-              <exclude>src/it/it1/src.apt</exclude>
+              <exclude>src/it/**/src.apt</exclude>
               <exclude>src/test/resources/unit/it2/src.txt</exclude>
               <exclude>src/test/resources/unit/it3/src.apt</exclude>
               <exclude>src/test/resources/unit/it4/*.html</exclude>
@@ -131,13 +131,8 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-invoker-plugin</artifactId>
-        <version>1.10</version>
         <configuration>
-          <projectsDirectory>src/it</projectsDirectory>
           <cloneProjectsTo>${project.build.directory}/invoker</cloneProjectsTo>
-          <pomIncludes>
-            <pomInclude>*/pom.xml</pomInclude>
-          </pomIncludes>
           
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
           <settingsFile>src/it/settings.xml</settingsFile>
           <postBuildHookScript>verify</postBuildHookScript>
@@ -247,6 +242,11 @@
       <artifactId>plexus-utils</artifactId>
       <version>3.0.21</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-lang3</artifactId>
+      <version>3.5</version>
+    </dependency>
   </dependencies>
   <reporting>
     <plugins>
diff --git a/apache-rat-plugin/src/it/RAT-268/invoker.properties 
b/apache-rat-plugin/src/it/RAT-268/invoker.properties
new file mode 100644
index 0000000..6e8c347
--- /dev/null
+++ b/apache-rat-plugin/src/it/RAT-268/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 apache-rat:check
diff --git a/apache-rat-plugin/src/it/RAT-268/module1/pom.xml 
b/apache-rat-plugin/src/it/RAT-268/module1/pom.xml
new file mode 100644
index 0000000..896861e
--- /dev/null
+++ b/apache-rat-plugin/src/it/RAT-268/module1/pom.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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>
+  <parent>
+    <groupId>org.apache.rat.test</groupId>
+    <artifactId>rat268</artifactId>
+    <version>1.0</version>
+  </parent>
+  <artifactId>module1</artifactId>
+</project>
diff --git a/apache-rat-plugin/src/it/RAT-268/module1/src.apt 
b/apache-rat-plugin/src/it/RAT-268/module1/src.apt
new file mode 100644
index 0000000..01ab206
--- /dev/null
+++ b/apache-rat-plugin/src/it/RAT-268/module1/src.apt
@@ -0,0 +1,12 @@
+~~   Yet Another License, just for test purposes
+
+    --------------
+    Some text file
+    --------------
+
+Some text file
+
+  This is a text file, which intentionally has no Apache License Header.
+  Instead, it contains a dummy license header. The Rat plugin should
+  accept it with a proper custom license matcher.
+
diff --git a/apache-rat-plugin/src/it/RAT-268/module2/module2.pom 
b/apache-rat-plugin/src/it/RAT-268/module2/module2.pom
new file mode 100644
index 0000000..341b911
--- /dev/null
+++ b/apache-rat-plugin/src/it/RAT-268/module2/module2.pom
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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>
+  <parent>
+    <groupId>org.apache.rat.test</groupId>
+    <artifactId>rat268</artifactId>
+    <version>1.0</version>
+  </parent>
+  <artifactId>module2</artifactId>
+</project>
diff --git a/apache-rat-plugin/src/it/RAT-268/module2/src.apt 
b/apache-rat-plugin/src/it/RAT-268/module2/src.apt
new file mode 100644
index 0000000..01ab206
--- /dev/null
+++ b/apache-rat-plugin/src/it/RAT-268/module2/src.apt
@@ -0,0 +1,12 @@
+~~   Yet Another License, just for test purposes
+
+    --------------
+    Some text file
+    --------------
+
+Some text file
+
+  This is a text file, which intentionally has no Apache License Header.
+  Instead, it contains a dummy license header. The Rat plugin should
+  accept it with a proper custom license matcher.
+
diff --git a/apache-rat-plugin/src/it/RAT-268/module3/pom.xml 
b/apache-rat-plugin/src/it/RAT-268/module3/pom.xml
new file mode 100644
index 0000000..2f41709
--- /dev/null
+++ b/apache-rat-plugin/src/it/RAT-268/module3/pom.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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>
+  <parent>
+    <groupId>org.apache.rat.test</groupId>
+    <artifactId>rat268</artifactId>
+    <version>1.0</version>
+  </parent>
+  <artifactId>module3</artifactId>
+</project>
diff --git a/apache-rat-plugin/src/it/RAT-268/module3/src.apt 
b/apache-rat-plugin/src/it/RAT-268/module3/src.apt
new file mode 100644
index 0000000..01ab206
--- /dev/null
+++ b/apache-rat-plugin/src/it/RAT-268/module3/src.apt
@@ -0,0 +1,12 @@
+~~   Yet Another License, just for test purposes
+
+    --------------
+    Some text file
+    --------------
+
+Some text file
+
+  This is a text file, which intentionally has no Apache License Header.
+  Instead, it contains a dummy license header. The Rat plugin should
+  accept it with a proper custom license matcher.
+
diff --git a/apache-rat-plugin/src/it/RAT-268/pom.xml 
b/apache-rat-plugin/src/it/RAT-268/pom.xml
new file mode 100644
index 0000000..8886a6c
--- /dev/null
+++ b/apache-rat-plugin/src/it/RAT-268/pom.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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>rat268</artifactId>
+  <version>1.0</version>
+  <packaging>pom</packaging>
+  
+  <modules>
+    <module>module1</module>
+    <module>module2/module2.pom</module>
+    <module>module3/pom.xml</module>
+  </modules>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.rat</groupId>
+        <artifactId>apache-rat-plugin</artifactId>
+        <version>@pom.version@</version>
+        <configuration>
+          <excludes>
+            <exclude>src.apt</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
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 7dec350..6d451f8 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
@@ -48,6 +48,7 @@ import javax.xml.transform.TransformerConfigurationException;
 
 
 import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -438,7 +439,12 @@ public abstract class AbstractRatMojo extends AbstractMojo 
{
                 && project.getModules() != null) {
             for (final Object o : project.getModules()) {
                 final String moduleSubPath = (String) o;
-                results.add(moduleSubPath + "/**/*");
+                if (new File( basedir, moduleSubPath ).isDirectory()) {
+                    results.add(moduleSubPath + "/**/*");
+                }
+                else {
+                    results.add(StringUtils.substringBeforeLast( 
moduleSubPath, "/" ) + "/**/*");
+                }
             }
         }
 

Reply via email to