From b401c5a3406eaa11b62d02d49c48b8f88a20c2b2 Mon Sep 17 00:00:00 2001 From: Thomas Canava Date: Mon, 12 Aug 2024 15:46:16 +0200 Subject: [PATCH] Make the boot jars in jib respect current timestamp --- .../image/jib/deployment/JibProcessor.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java b/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java index 3b93e633ec946..9f7a2b4330bb4 100644 --- a/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java +++ b/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java @@ -540,15 +540,20 @@ private JibContainerBuilder createContainerBuilderFromFastJar(String baseJvmImag FileEntriesLayer.Builder bootLibsLayerBuilder = FileEntriesLayer.builder().setName("fast-jar-boot-libs"); Path bootLibPath = componentsPath.resolve(JarResultBuildStep.LIB).resolve(JarResultBuildStep.BOOT_LIB); - try (Stream boolLibPaths = Files.list(bootLibPath)) { - boolLibPaths.forEach(lib -> { + try (Stream bootLibPaths = Files.list(bootLibPath)) { + bootLibPaths.forEach(lib -> { try { AbsoluteUnixPath libPathInContainer = workDirInContainer.resolve(JarResultBuildStep.LIB) .resolve(JarResultBuildStep.BOOT_LIB) .resolve(lib.getFileName()); - // the boot lib jars need to preserve the modification time because otherwise AppCDS won't work - bootLibsLayerBuilder.addEntry(lib, libPathInContainer, - Files.getLastModifiedTime(lib).toInstant()); + Instant bootLibModificationTime; + if (appCDSResult.isPresent()) { + // the boot lib jars need to preserve the modification time because otherwise AppCDS won't work + bootLibModificationTime = Files.getLastModifiedTime(lib).toInstant(); + } else { + bootLibModificationTime = modificationTime; + } + bootLibsLayerBuilder.addEntry(lib, libPathInContainer, bootLibModificationTime); } catch (IOException e) { throw new UncheckedIOException(e); }