From 302c53a8e70c9e37c03e0d2650d4083f370bf647 Mon Sep 17 00:00:00 2001 From: Viktor Lofgren Date: Fri, 5 Jan 2024 13:19:59 +0100 Subject: [PATCH] (build) Enable reproducible builds in build.gradle Settings for enabling reproducible builds for all subprojects were added to improve build consistency. This includes preserving file timestamps and ordering files reproducibly. This is primarily of help for docker, since it uses hashes to determine if a file or image layer has changed. --- build.gradle | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index d7f74837..4bda69de 100644 --- a/build.gradle +++ b/build.gradle @@ -11,8 +11,8 @@ version 'SNAPSHOT' compileJava.options.encoding = "UTF-8" compileTestJava.options.encoding = "UTF-8" -// Enable preview features for the entire project subprojects.forEach {it -> + // Enable preview features for the entire project it.tasks.withType(JavaCompile).configureEach { options.compilerArgs += ['--enable-preview'] } @@ -22,6 +22,12 @@ subprojects.forEach {it -> it.tasks.withType(Test).configureEach { jvmArgs += ['--enable-preview'] } + + // Enable reproducible builds for the entire project + it.tasks.withType(AbstractArchiveTask).configureEach { + preserveFileTimestamps = false + reproducibleFileOrder = true + } } allprojects {