|
14 | 14 | * limitations under the License. |
15 | 15 | */ |
16 | 16 |
|
17 | | -import java.io.File |
18 | | -import java.io.FileOutputStream |
19 | | -import java.nio.file.attribute.FileTime |
20 | | -import java.util.zip.ZipFile |
21 | | -import java.util.zip.ZipOutputStream |
22 | 17 | import org.gradle.api.Project |
23 | 18 | import org.gradle.process.JavaForkOptions |
24 | 19 |
|
@@ -66,41 +61,3 @@ fun JavaForkOptions.addSparkJvmOptions() { |
66 | 61 | "-Djdk.reflect.useDirectMethodHandle=false", |
67 | 62 | ) |
68 | 63 | } |
69 | | - |
70 | | -/** |
71 | | - * Rewrites the given ZIP file. |
72 | | - * |
73 | | - * The timestamps of all entries are set to `1980-02-01 00:00`, zip entries appear in a |
74 | | - * deterministic order. |
75 | | - */ |
76 | | -fun makeZipReproducible(source: File) { |
77 | | - val t = FileTime.fromMillis(318211200_000) // 1980-02-01 00:00 GMT |
78 | | - |
79 | | - val outFile = File(source.absolutePath + ".tmp.out") |
80 | | - |
81 | | - val names = mutableListOf<String>() |
82 | | - ZipFile(source).use { zip -> zip.stream().forEach { e -> names.add(e.name) } } |
83 | | - names.sort() |
84 | | - |
85 | | - ZipOutputStream(FileOutputStream(outFile)).use { dst -> |
86 | | - ZipFile(source).use { zip -> |
87 | | - names.forEach { n -> |
88 | | - val e = zip.getEntry(n) |
89 | | - zip.getInputStream(e).use { src -> |
90 | | - e.setCreationTime(t) |
91 | | - e.setLastAccessTime(t) |
92 | | - e.setLastModifiedTime(t) |
93 | | - dst.putNextEntry(e) |
94 | | - src.copyTo(dst) |
95 | | - dst.closeEntry() |
96 | | - src.close() |
97 | | - } |
98 | | - } |
99 | | - } |
100 | | - } |
101 | | - |
102 | | - val origFile = File(source.absolutePath + ".tmp.orig") |
103 | | - source.renameTo(origFile) |
104 | | - outFile.renameTo(source) |
105 | | - origFile.delete() |
106 | | -} |
0 commit comments