This is an automated email from the ASF dual-hosted git repository.
pottlinger 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 2baba8a5 RAT-379: Groovify proposed solution and shorten log output
during build
2baba8a5 is described below
commit 2baba8a594bc9f9ac057d357a3f088341ef094cc
Author: P. Ottlinger <[email protected]>
AuthorDate: Sun Dec 8 23:47:11 2024 +0100
RAT-379: Groovify proposed solution and shorten log output during build
---
.../copyResourcesFromParentProject.groovy | 69 +++++++++++-----------
1 file changed, 35 insertions(+), 34 deletions(-)
diff --git
a/apache-rat-core/src/main/build-grv/copyResourcesFromParentProject.groovy
b/apache-rat-core/src/main/build-grv/copyResourcesFromParentProject.groovy
index be232db9..e8501d6c 100644
--- a/apache-rat-core/src/main/build-grv/copyResourcesFromParentProject.groovy
+++ b/apache-rat-core/src/main/build-grv/copyResourcesFromParentProject.groovy
@@ -16,50 +16,51 @@
*/
// 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.
+// so that they become a part of the generated jar file. See RAT-379 for
details.
-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;
+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}")
-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);
+ final String msg = "Source directory not found: " +
sourceDir.toAbsolutePath()
+ System.err.println(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);
+
+// System.out.println("copyResourcesFromParent: Using source directory " +
sourceDir + ", resolved to " + sourceDir.toAbsolutePath())
+// System.out.println("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 String msg = "Source file " + token + " not found in
source directory " + sourceDir
+ System.err.println("copyResourcesFromParent: " + msg)
+ System.err.println("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);
+ 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;
+ final FileTime sourceTime =
Files.getLastModifiedTime(sourceFile)
+ final FileTime targetTime =
Files.getLastModifiedTime(targetFile)
+ if (sourceTime != null && targetTime != null && sourceTime
>= targetTime) {
+ System.out.println("Skipping " + sourceFile + ", as
target " + targetFile + " appears to be up-to-date already.")
+ continue
}
}
- log.debug("copyResourcesFromParent: Copying source file " + sourceFile
- + " to target file " + targetFile);
+ System.out.println("Copying " + sourceFile
+ + " to " + targetFile)
if (replacing) {
- Files.copy(sourceFile, targetFile,
StandardCopyOption.REPLACE_EXISTING);
+ Files.copy(sourceFile, targetFile,
StandardCopyOption.REPLACE_EXISTING)
} else {
- Files.copy(sourceFile, targetFile);
+ Files.copy(sourceFile, targetFile)
}
}