Produce deterministic jar files.
This resets all timestamps present in jars produced by kotlinc.
This is important for build systems like bazel that rely on
deterministic outputs.
Before:
```
$ kotlinc ~/test.kt -d /tmp/a.jar
$ kotlinc ~/test.kt -d /tmp/b.jar
9ab80cd40c9293a7a66adf1154d4e6e9aa92d5b0 /tmp/a.jar
1ba022697317f796bd123fb4dc95418a18bcb51a /tmp/a.jar
6d2a2683470c24928f3fbd6768a4c57f55b0d196 /tmp/b.jar
$ unzip -l /tmp/a.jar
Archive: /tmp/a.jar
Length Date Time Name
--------- ---------- ----- ----
75 09-25-2020 16:48 META-INF/MANIFEST.MF
683 09-25-2020 16:48 TestKt.class
28 09-25-2020 16:48 META-INF/main.kotlin_module
--------- -------
786 3 files
```
After:
```
$ kotlinc ~/test.kt -d /tmp/a.jar
$ kotlinc ~/test.kt -d /tmp/b.jar
$ shasum /tmp/a.jar /tmp/b.jar
9ab80cd40c9293a7a66adf1154d4e6e9aa92d5b0 /tmp/a.jar
9ab80cd40c9293a7a66adf1154d4e6e9aa92d5b0 /tmp/b.jar
$ unzip -l /tmp/a.jar
Archive: /tmp/a.jar
Length Date Time Name
--------- ---------- ----- ----
75 12-31-1969 19:00 META-INF/MANIFEST.MF
590 12-31-1969 19:00 TestKt.class
36 12-31-1969 19:00 META-INF/main.kotlin_module
--------- -------
701 3 files
```
See https://github.com/JetBrains/kotlin/pull/3226 for a similar change.
This commit is contained in:
committed by
Alexander Udalov
parent
a3830b2611
commit
68fdeaf865
+6
@@ -377,6 +377,12 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
)
|
||||
var noKotlinNothingValueException: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xno-reset-jar-timestamps",
|
||||
description = "Do not reset jar entry timestamps to a fixed date"
|
||||
)
|
||||
var noResetJarTimestamps: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xno-unified-null-checks",
|
||||
description = "Use pre-1.4 exception types in null checks instead of java.lang.NPE. See KT-22275 for more details"
|
||||
|
||||
Reference in New Issue
Block a user