From 9a283159b80d70df19ef5938c27b30e46ac3ce99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Sat, 19 Aug 2023 19:21:20 +0200 Subject: [PATCH] Make sure the last modified timestamp is set correctly Linux stores modification time with nano-seconds precision, but we currently set the timestamp of the cached file only in milliseconds. This can lead to the situation that the source is considered a few nanoseconds older than the cache file and therefore the cache is regenerated every time. --- .../org/eclipse/m2e/pde/target/shared/MavenBundleWrapper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tycho-core/src/main/java/org/eclipse/m2e/pde/target/shared/MavenBundleWrapper.java b/tycho-core/src/main/java/org/eclipse/m2e/pde/target/shared/MavenBundleWrapper.java index ce2374ceb9..c7542f4ffc 100644 --- a/tycho-core/src/main/java/org/eclipse/m2e/pde/target/shared/MavenBundleWrapper.java +++ b/tycho-core/src/main/java/org/eclipse/m2e/pde/target/shared/MavenBundleWrapper.java @@ -235,7 +235,7 @@ private static WrappedBundle getWrappedNode(DependencyNode node, messages.add(new ProcessingMessage(artifact, Type.WARN, warn)); } } - wrapArtifactFile.setLastModified(originalFile.lastModified()); + Files.setLastModifiedTime(wrapArtifactFile.toPath(), Files.getLastModifiedTime(originalFile.toPath())); visited.put(node, wrappedNode = new WrappedBundle(node, depends, key, wrapArtifactFile.toPath(), new Jar(wrapArtifactFile), messages)); } else { @@ -301,7 +301,7 @@ public static boolean isOutdated(Path cacheFile, Path sourceFile) throws IOExcep if (Files.exists(cacheFile)) { FileTime sourceTimeStamp = Files.getLastModifiedTime(sourceFile); FileTime cacheTimeStamp = Files.getLastModifiedTime(cacheFile); - return sourceTimeStamp.compareTo(cacheTimeStamp) > 0; + return sourceTimeStamp.toMillis() > cacheTimeStamp.toMillis(); } return true; }