File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
gradle/plugins/common/src/main/kotlin/junitbuild/java Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -8,18 +8,31 @@ import org.gradle.api.provider.Property
88import org.gradle.jvm.toolchain.JavaLauncher
99import org.gradle.process.ExecOperations
1010import java.time.Instant
11+ import java.time.LocalDateTime
12+ import java.time.ZoneId
13+ import java.time.ZoneOffset
1114import javax.inject.Inject
1215
1316abstract class UpdateJarAction @Inject constructor(private val operations : ExecOperations ): Action<Task> {
1417
18+ companion object {
19+ // Since ZipCopyAction.CONSTANT_TIME_FOR_ZIP_ENTRIES is in the default time zone (see its Javadoc),
20+ // we're converting it to the same time in UTC here to make the jar reproducible regardless of the
21+ // build's time zone.
22+ private val CONSTANT_TIME_FOR_ZIP_ENTRIES = LocalDateTime .ofInstant(Instant .ofEpochMilli(ZipCopyAction .CONSTANT_TIME_FOR_ZIP_ENTRIES ), ZoneId .systemDefault())
23+ .toInstant(ZoneOffset .UTC )
24+ .toString()
25+ }
26+
1527 abstract val javaLauncher: Property <JavaLauncher >
1628
1729 abstract val args: ListProperty <String >
1830
1931 init {
2032 args.convention(listOf (
2133 " --update" ,
22- " --date=${Instant .ofEpochMilli(ZipCopyAction .CONSTANT_TIME_FOR_ZIP_ENTRIES )} " ,
34+ // Use a constant time to make the JAR reproducible.
35+ " --date=$CONSTANT_TIME_FOR_ZIP_ENTRIES " ,
2336 ))
2437 }
2538
You can’t perform that action at this time.
0 commit comments