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

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


The following commit(s) were added to refs/heads/feature/RAT-379 by this push:
     new 9a860ae1 Using the maven-dependency-plugin to distribute the release 
notes among subprojects.
9a860ae1 is described below

commit 9a860ae1f44089cc8732f1c270246bf15cbd5646
Author: Jochen Wiedmann <[email protected]>
AuthorDate: Wed Dec 4 00:51:01 2024 +0100

    Using the maven-dependency-plugin to distribute the release notes among 
subprojects.
---
 .gitignore                                         |  2 +
 apache-rat-core/pom.xml                            | 54 ++++++++++++++++++
 .../copyResourcesFromParentProject.groovy          | 65 ++++++++++++++++++++++
 apache-rat-plugin/pom.xml                          | 35 ++++++++++++
 apache-rat-tasks/pom.xml                           | 17 ++++++
 apache-rat-tools/pom.xml                           |  4 ++
 6 files changed, 177 insertions(+)

diff --git a/.gitignore b/.gitignore
index 39048c2c..e21f4d44 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,3 +22,5 @@
 **/bin
 **/.mvn/.develocity*
 **/src/site/apt/*.txt
+**/.checkstyle
+**/.externalToolBuilders/**/*
diff --git a/apache-rat-core/pom.xml b/apache-rat-core/pom.xml
index 557fde87..3480e870 100644
--- a/apache-rat-core/pom.xml
+++ b/apache-rat-core/pom.xml
@@ -44,6 +44,10 @@
           <artifactId>apache-rat-plugin</artifactId>
           <configuration>
             <excludes>
+              <!-- Generated by Eclipse, and not distributed, so ignorable. -->
+              <exclude>bin/**/*</exclude>
+              <exclude>.externalToolBuilders/**/*</exclude>
+
               <!-- These files have bad license headers because they are used 
to test bad license headers -->
               <exclude>src/test/resources/**</exclude>
               <exclude>src/it/resources/ReportTest/**</exclude>
@@ -52,9 +56,59 @@
             </excludes>
           </configuration>
         </plugin>
+        <!--This plugin's configuration is used to store Eclipse m2e settings 
only. It has no influence on the Maven build itself.-->
+        <plugin>
+               <groupId>org.eclipse.m2e</groupId>
+               <artifactId>lifecycle-mapping</artifactId>
+               <version>1.0.0</version>
+               <configuration>
+                       <lifecycleMappingMetadata>
+                               <pluginExecutions>
+                                       <pluginExecution>
+                                               <pluginExecutionFilter>
+                                                       <groupId>
+                                                               
com.github.jochenw.jmp
+                                                       </groupId>
+                                                       <artifactId>
+                                                               
jwigrv-maven-plugin
+                                                       </artifactId>
+                                                       
<versionRange>[0.2,)</versionRange>
+                                                       <goals>
+                                                               <goal>run</goal>
+                                                       </goals>
+                                               </pluginExecutionFilter>
+                                               <action>
+                                                       <ignore></ignore>
+                                               </action>
+                                       </pluginExecution>
+                               </pluginExecutions>
+                       </lifecycleMappingMetadata>
+               </configuration>
+        </plugin>
       </plugins>
     </pluginManagement>
     <plugins>
+      <plugin>
+        <groupId>com.github.jochenw.jmp</groupId>
+        <artifactId>jwigrv-maven-plugin</artifactId>
+        <version>0.2</version>
+        <executions>
+          <!-- Run Groovy script, which copies resource files from the parent 
project. -->
+          <execution>
+            <phase>generate-resources</phase>
+            <goals><goal>run</goal></goals>
+            <configuration>
+              
<scriptFile>src/main/build-grv/copyResourcesFromParentProject.groovy</scriptFile>
+              <scriptProperties>
+                <!-- Where -->
+                <sourceDir>${project.basedir}/..</sourceDir>
+                
<targetDir>${project.build.outputDirectory}/META-INF</targetDir>
+                <filesToCopy>RELEASE_NOTES.txt</filesToCopy>
+              </scriptProperties>
+            </configuration> 
+          </execution> 
+        </executions>   
+      </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-jar-plugin</artifactId>
diff --git 
a/apache-rat-core/src/main/build-grv/copyResourcesFromParentProject.groovy 
b/apache-rat-core/src/main/build-grv/copyResourcesFromParentProject.groovy
new file mode 100644
index 00000000..be232db9
--- /dev/null
+++ b/apache-rat-core/src/main/build-grv/copyResourcesFromParentProject.groovy
@@ -0,0 +1,65 @@
+/**
+ * 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.
+ */
+
+// Copy a set of resource files from the parent project to 
target/classes/META-INF,
+// so that they become a part of the generated jar file. See RAT-379.
+
+import java.io.FileNotFoundException;
+import java.nio.file.attribute.FileTime;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+
+final Path sourceDir = Paths.get("${sourceDir}");
+final Path targetDir = Paths.get("${targetDir}");
+if (!Files.isDirectory(sourceDir)) {
+       final String msg = "Source directory not found: " + 
sourceDir.toAbsolutePath();
+       log.error(msg);
+       throw new FileNotFoundException(msg);
+}
+log.debug("copyResourcesFromParent: Using source directory " + sourceDir + ", 
resolved to " + sourceDir.toAbsolutePath());
+log.debug("copyResourcesFromParent: Using target directory " + targetDir + ", 
resolved to " + targetDir.toAbsolutePath());
+Files.createDirectories(targetDir);
+for (StringTokenizer st = new StringTokenizer("${filesToCopy}",  ",");  
st.hasMoreTokens();  ) {
+       final String token = st.nextToken();
+       final Path sourceFile = sourceDir.resolve(token);
+       if (!Files.isRegularFile(sourceFile)) {
+               final String msg = "Source file " + token + " not found in 
source directory " + sourceDir;
+               log.error("copyResourcesFromParent: " + msg);
+               log.error("copyResourcesFromParent: A possible reason is, that 
you did clone only the apache-rat-core subproject from Git.");
+           throw new FileNotFoundException(msg);
+       }
+       final Path targetFile = targetDir.resolve(token);
+       final boolean replacing = Files.isRegularFile(targetFile);
+       if (replacing) {
+               final FileTime sourceTime = 
Files.getLastModifiedTime(sourceFile);
+               final FileTime targetTime = 
Files.getLastModifiedTime(targetFile);
+               if (sourceTime != null  &&  targetTime != null  &&  
sourceTime.compareTo(targetTime) >= 0) {
+                       log.debug("copyResourcesFromParent: Skipping source 
file "
+                                 + sourceFile + ", because target file " + 
targetFile + " appears to be uptodate.");
+                       continue;
+           }
+       }
+       log.debug("copyResourcesFromParent: Copying source file " + sourceFile
+                 + " to target file " + targetFile);
+       if (replacing) {
+               Files.copy(sourceFile, targetFile, 
StandardCopyOption.REPLACE_EXISTING);
+       } else {
+               Files.copy(sourceFile, targetFile);
+       }
+}
diff --git a/apache-rat-plugin/pom.xml b/apache-rat-plugin/pom.xml
index e2310fee..def7dab4 100644
--- a/apache-rat-plugin/pom.xml
+++ b/apache-rat-plugin/pom.xml
@@ -85,6 +85,10 @@
           <artifactId>apache-rat-plugin</artifactId>
           <configuration>
             <excludes>
+              <!-- Generated by Eclipse, and not distributed, so ignorable. -->
+              <exclude>bin/**/*</exclude>
+              <exclude>.externalToolBuilders/**/*</exclude>
+
               <!-- These files do not have license headers because they are 
used to test license headers -->
               <exclude>src/it/**</exclude>
               <exclude>src/it/**/src.apt</exclude>
@@ -122,6 +126,19 @@
                     <ignore/>
                   </action>
                 </pluginExecution>
+                <pluginExecution>
+                       <pluginExecutionFilter>
+                               <groupId>org.codehaus.mojo</groupId>
+                               <artifactId>exec-maven-plugin</artifactId>
+                               <versionRange>[3.5.0,)</versionRange>
+                               <goals>
+                                       <goal>java</goal>
+                               </goals>
+                       </pluginExecutionFilter>
+                       <action>
+                               <ignore></ignore>
+                       </action>
+                </pluginExecution>
               </pluginExecutions>
             </lifecycleMappingMetadata>
           </configuration>
@@ -129,6 +146,24 @@
       </plugins>
     </pluginManagement>
     <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <executions>
+          <!-- Copy resource files from the apache-rat-core project. -->
+          <execution>
+            <id>copy-release-notes-from-core</id>
+            <goals><goal>unpack-dependencies</goal></goals>
+            <phase>generate-resources</phase>
+            <configuration>
+              <includeArtifactIds>apache-rat-core</includeArtifactIds>
+              <excludeClassifiers>tests</excludeClassifiers>
+              <include>META-INF/RELEASE_NOTES.txt</include>
+              
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>  
       <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>exec-maven-plugin</artifactId>
diff --git a/apache-rat-tasks/pom.xml b/apache-rat-tasks/pom.xml
index 4b0eeb03..d255136f 100644
--- a/apache-rat-tasks/pom.xml
+++ b/apache-rat-tasks/pom.xml
@@ -235,6 +235,10 @@
           <artifactId>apache-rat-plugin</artifactId>
           <configuration>
             <excludes>
+              <!-- Generated by Eclipse, and not distributed, so ignorable. -->
+              <exclude>bin/**/*</exclude>
+              <exclude>.externalToolBuilders/**/*</exclude>
+
               <!-- These files do not have license headers -->
               <exclude>src/test/resources/</exclude>
               <exclude>src/site/apt/*.txt</exclude>
@@ -261,6 +265,19 @@
                     <ignore/>
                   </action>
                 </pluginExecution>
+                <pluginExecution>
+                       <pluginExecutionFilter>
+                               <groupId>org.codehaus.mojo</groupId>
+                               <artifactId>exec-maven-plugin</artifactId>
+                               <versionRange>[3.5.0,)</versionRange>
+                               <goals>
+                                       <goal>java</goal>
+                               </goals>
+                       </pluginExecutionFilter>
+                       <action>
+                               <ignore></ignore>
+                       </action>
+                </pluginExecution>
               </pluginExecutions>
             </lifecycleMappingMetadata>
           </configuration>
diff --git a/apache-rat-tools/pom.xml b/apache-rat-tools/pom.xml
index 821a22e1..4579ffcb 100644
--- a/apache-rat-tools/pom.xml
+++ b/apache-rat-tools/pom.xml
@@ -44,6 +44,10 @@
           <artifactId>apache-rat-plugin</artifactId>
           <configuration>
             <excludes>
+              <!-- Generated by Eclipse, and not distributed, so ignorable. -->
+              <exclude>bin/**/*</exclude>
+              <exclude>.externalToolBuilders/**/*</exclude>
+
               <!-- This file is included into a generated file. -->
               <exclude>src/main/resources/Args.tpl</exclude>
               <exclude>src/main/resources/ant/report.tpl</exclude>

Reply via email to