From 88ee343e9561ead81fed07785d39b80d51f83085 Mon Sep 17 00:00:00 2001 From: Milen Dobrinov <16443261+milen-dobrinov@users.noreply.github.com> Date: Mon, 26 Nov 2018 19:31:31 +0200 Subject: [PATCH] [CORDA-2189] Fix non deterministic manifest file timestamp (#4301) --- .../net/corda/testing/node/internal/TestCordappsUtils.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/TestCordappsUtils.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/TestCordappsUtils.kt index 241a5cc7e3..471142ce60 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/TestCordappsUtils.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/TestCordappsUtils.kt @@ -4,9 +4,11 @@ import io.github.classgraph.ClassGraph import net.corda.core.internal.outputStream import net.corda.node.internal.cordapp.createTestManifest import net.corda.testing.node.TestCordapp +import java.io.BufferedOutputStream import java.nio.file.Path import java.nio.file.attribute.FileTime import java.time.Instant +import java.util.jar.JarFile import java.util.jar.JarOutputStream import java.util.zip.ZipEntry import kotlin.reflect.KClass @@ -65,8 +67,13 @@ fun TestCordappImpl.packageAsJar(file: Path) { scanResult.use { val manifest = createTestManifest(name, title, version, vendor, targetVersion) - JarOutputStream(file.outputStream(), manifest).use { jos -> + JarOutputStream(file.outputStream()).use { jos -> val time = FileTime.from(Instant.EPOCH) + val manifestEntry = ZipEntry(JarFile.MANIFEST_NAME).setCreationTime(time).setLastAccessTime(time).setLastModifiedTime(time) + jos.putNextEntry(manifestEntry) + manifest.write(BufferedOutputStream(jos)) + jos.closeEntry() + // The same resource may be found in different locations (this will happen when running from gradle) so just // pick the first one found. scanResult.allResources.asMap().forEach { path, resourceList ->