From e6dab2816acfb17262ab56f87ec77621bc0d1d72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Mon, 25 Dec 2023 11:23:09 +0100 Subject: [PATCH] Check if file (still)is present in the ZipComparator If nested jars are compared the file of the baseline is only transient and can't be accessed after the compare. In this case, simply do not copy the files and instead assume it was already written out as part of the outer comparison delta operation. --- .../zipcomparator/internal/ZipComparatorImpl.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tycho-artifactcomparator/src/main/java/org/eclipse/tycho/zipcomparator/internal/ZipComparatorImpl.java b/tycho-artifactcomparator/src/main/java/org/eclipse/tycho/zipcomparator/internal/ZipComparatorImpl.java index e68c5f07c9..a1de7efc13 100644 --- a/tycho-artifactcomparator/src/main/java/org/eclipse/tycho/zipcomparator/internal/ZipComparatorImpl.java +++ b/tycho-artifactcomparator/src/main/java/org/eclipse/tycho/zipcomparator/internal/ZipComparatorImpl.java @@ -17,6 +17,7 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; +import java.nio.file.StandardCopyOption; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; @@ -99,9 +100,16 @@ public ZipArtifactDelta(Map members, File basel @Override public void writeDetails(File basedir) throws IOException { + basedir.mkdirs(); super.writeDetails(basedir); - Files.copy(baseline.toPath(), basedir.toPath().resolve("baseline-" + baseline.getName())); - Files.copy(reactor.toPath(), basedir.toPath().resolve("build-" + reactor.getName())); + if (baseline.isFile()) { + Files.copy(baseline.toPath(), basedir.toPath().resolve("baseline-" + baseline.getName()), + StandardCopyOption.REPLACE_EXISTING); + } + if (reactor.isFile()) { + Files.copy(reactor.toPath(), basedir.toPath().resolve("build-" + reactor.getName()), + StandardCopyOption.REPLACE_EXISTING); + } } }