Hi,

this looks rather hacky to me .....
a groovy file full of Java code .....


Does the build still run in a single submodule? Does the site build run well?

Cheers,
Phil


Am 01.12.24 um 22:43 schrieb [email protected]:
This is an automated email from the ASF dual-hosted git repository.

jochen 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 3d514a32 Using the JWI Groovy Maven plugin to add RELEASE_NOTES.txt 
to the apache-rat-core jar file.
3d514a32 is described below

commit 3d514a3230e79c0095bab1776be206dfe718be67
Author: Jochen Wiedmann <[email protected]>
AuthorDate: Sun Dec 1 22:40:40 2024 +0100

     Using the JWI Groovy Maven plugin to add RELEASE_NOTES.txt to the 
apache-rat-core jar file.
---
  apache-rat-core/pom.xml                            | 36 ++++++++++---
  .../main/build-grv/copyResourcesFromParent.groovy  | 59 ++++++++++++++++++++++
  apache-rat-plugin/pom.xml                          | 13 +++--
  apache-rat-tasks/pom.xml                           | 13 +++--
  apache-rat-tools/pom.xml                           | 13 +++--
  apache-rat/pom.xml                                 | 17 +++----
  6 files changed, 112 insertions(+), 39 deletions(-)

diff --git a/apache-rat-core/pom.xml b/apache-rat-core/pom.xml
index 8a500a5f..1d41667a 100644
--- a/apache-rat-core/pom.xml
+++ b/apache-rat-core/pom.xml
@@ -36,13 +36,6 @@
          <filtering>true</filtering>
          <directory>src/main/filtered-resources</directory>
        </resource>
-      <resource>
-        <directory>..</directory>
-        <targetPath>META-INF</targetPath>
-        <includes>
-          <include>RELEASE_NOTES.txt</include>
-        </includes>
-      </resource>
      </resources>
      <pluginManagement>
        <plugins>
@@ -51,6 +44,12 @@
            <artifactId>apache-rat-plugin</artifactId>
            <configuration>
              <excludes>
+              <!-- Generated by Eclipse, thus ignorable. -->
+              <exclude>.classpath</exclude>
+              <exclude>.project</exclude>
+              <exclude>.settings/**/*</exclude>
+              <exclude>bin/**/*</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>
@@ -136,6 +135,29 @@
            </execution>
          </executions>
        </plugin>
+     <plugin>
+       <groupId>com.github.jochenw.jmp</groupId>
+       <artifactId>jwigrv-maven-plugin</artifactId>
+       <version>0.1</version>
+       <executions>
+         <execution>
+           <!-- 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.
+           -->
+           <phase>generate-resources</phase>
+           <goals><goal>run</goal></goals>
+           <configuration>
+            
<scriptFile>src/main/build-grv/copyResourcesFromParent.groovy</scriptFile>
+            <scriptProperties>
+              <sourceDir>${basedir}/..</sourceDir>
+              <targetDir>${project.build.outputDirectory}/META-INF</targetDir>
+              <!-- Comma separated list of files, which are being copied -->
+              <filesToCopy>RELEASE_NOTES.txt</filesToCopy>
+            </scriptProperties>
+           </configuration>
+         </execution>
+       </executions>
+     </plugin>
      </plugins>
    </build>
    <dependencies>
diff --git a/apache-rat-core/src/main/build-grv/copyResourcesFromParent.groovy 
b/apache-rat-core/src/main/build-grv/copyResourcesFromParent.groovy
new file mode 100644
index 00000000..8e54ca63
--- /dev/null
+++ b/apache-rat-core/src/main/build-grv/copyResourcesFromParent.groovy
@@ -0,0 +1,59 @@
+/**
+ * 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;
+
+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);
+       if (Files.isRegularFile(targetFile)) {
+               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);
+       Files.copy(sourceFile, targetFile);
+}
\ No newline at end of file
diff --git a/apache-rat-plugin/pom.xml b/apache-rat-plugin/pom.xml
index 739982a2..02e0000d 100644
--- a/apache-rat-plugin/pom.xml
+++ b/apache-rat-plugin/pom.xml
@@ -46,13 +46,6 @@
          <filtering>true</filtering>
          <directory>src/main/filtered-resources</directory>
        </resource>
-      <resource>
-        <directory>..</directory>
-        <targetPath>META-INF</targetPath>
-        <includes>
-          <include>RELEASE_NOTES.txt</include>
-        </includes>
-      </resource>
      </resources>
      <testResources>
        <testResource>
@@ -92,6 +85,12 @@
            <artifactId>apache-rat-plugin</artifactId>
            <configuration>
              <excludes>
+              <!-- Generated by Eclipse, thus ignorable. -->
+              <exclude>.classpath</exclude>
+              <exclude>.project</exclude>
+              <exclude>.settings/**/*</exclude>
+              <exclude>bin/**/*</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>
diff --git a/apache-rat-tasks/pom.xml b/apache-rat-tasks/pom.xml
index 32f7b5d7..28eb901e 100644
--- a/apache-rat-tasks/pom.xml
+++ b/apache-rat-tasks/pom.xml
@@ -82,13 +82,6 @@
          <filtering>true</filtering>
          <directory>src/main/filtered-resources</directory>
        </resource>
-      <resource>
-        <directory>..</directory>
-        <targetPath>META-INF</targetPath>
-        <includes>
-          <include>RELEASE_NOTES.txt</include>
-        </includes>
-      </resource>
      </resources>
      <plugins>
        <plugin>
@@ -242,6 +235,12 @@
            <artifactId>apache-rat-plugin</artifactId>
            <configuration>
              <excludes>
+              <!-- Generated by Eclipse, thus ignorable. -->
+              <exclude>.classpath</exclude>
+              <exclude>.project</exclude>
+              <exclude>.settings/**/*</exclude>
+              <exclude>bin/**/*</exclude>
+
                <!-- These files do not have license headers -->
                <exclude>src/test/resources/</exclude>
                <exclude>src/site/apt/*.txt</exclude>
diff --git a/apache-rat-tools/pom.xml b/apache-rat-tools/pom.xml
index 8ae90987..52e777ff 100644
--- a/apache-rat-tools/pom.xml
+++ b/apache-rat-tools/pom.xml
@@ -36,13 +36,6 @@
          <filtering>true</filtering>
          <directory>src/main/filtered-resources</directory>
        </resource>
-      <resource>
-        <directory>..</directory>
-        <targetPath>META-INF</targetPath>
-        <includes>
-          <include>RELEASE_NOTES.txt</include>
-        </includes>
-      </resource>
      </resources>
      <pluginManagement>
        <plugins>
@@ -51,6 +44,12 @@
            <artifactId>apache-rat-plugin</artifactId>
            <configuration>
              <excludes>
+              <!-- Generated by Eclipse, thus ignorable. -->
+              <exclude>.classpath</exclude>
+              <exclude>.project</exclude>
+              <exclude>.settings/**/*</exclude>
+              <exclude>bin/**/*</exclude>
+
                <!-- This file is included into a generated file. -->
                <exclude>src/main/resources/Args.tpl</exclude>
                <exclude>src/main/resources/ant/report.tpl</exclude>
diff --git a/apache-rat/pom.xml b/apache-rat/pom.xml
index 55916e53..72e50296 100644
--- a/apache-rat/pom.xml
+++ b/apache-rat/pom.xml
@@ -42,17 +42,6 @@
      </dependency>
    </dependencies>
    <build>
-    <resources>
-      <resource>
-        <directory>..</directory>
-        <targetPath>META-INF</targetPath>
-        <includes>
-          <include>RELEASE_NOTES.txt</include>
-          <include>LICENSE</include>
-          <include>NOTICE</include>
-        </includes>
-      </resource>
-    </resources>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
@@ -219,6 +208,12 @@
            <artifactId>apache-rat-plugin</artifactId>
            <configuration>
              <excludes>
+              <!-- Generated by Eclipse, thus ignorable. -->
+              <exclude>.classpath</exclude>
+              <exclude>.project</exclude>
+              <exclude>.settings/**/*</exclude>
+              <exclude>bin/**/*</exclude>
+
                <!-- These files only describe how to use the project and they
                     have no license headers -->
                <exclude>README-ANT.txt</exclude>


Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to