[CORDA-2189] Fix non deterministic manifest file timestamp (#4301)

This commit is contained in:
Milen Dobrinov 2018-11-26 19:31:31 +02:00 committed by Viktor Kolomeyko
parent b7d04b1c6e
commit 88ee343e95

View File

@ -4,9 +4,11 @@ import io.github.classgraph.ClassGraph
import net.corda.core.internal.outputStream import net.corda.core.internal.outputStream
import net.corda.node.internal.cordapp.createTestManifest import net.corda.node.internal.cordapp.createTestManifest
import net.corda.testing.node.TestCordapp import net.corda.testing.node.TestCordapp
import java.io.BufferedOutputStream
import java.nio.file.Path import java.nio.file.Path
import java.nio.file.attribute.FileTime import java.nio.file.attribute.FileTime
import java.time.Instant import java.time.Instant
import java.util.jar.JarFile
import java.util.jar.JarOutputStream import java.util.jar.JarOutputStream
import java.util.zip.ZipEntry import java.util.zip.ZipEntry
import kotlin.reflect.KClass import kotlin.reflect.KClass
@ -65,8 +67,13 @@ fun TestCordappImpl.packageAsJar(file: Path) {
scanResult.use { scanResult.use {
val manifest = createTestManifest(name, title, version, vendor, targetVersion) 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 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 // The same resource may be found in different locations (this will happen when running from gradle) so just
// pick the first one found. // pick the first one found.
scanResult.allResources.asMap().forEach { path, resourceList -> scanResult.allResources.asMap().forEach { path, resourceList ->