(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.
This commit is contained in:
Viktor Lofgren 2024-01-05 13:19:59 +01:00
parent ef02b712ad
commit 302c53a8e7

View file

@ -11,8 +11,8 @@ version 'SNAPSHOT'
compileJava.options.encoding = "UTF-8" compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8" compileTestJava.options.encoding = "UTF-8"
// Enable preview features for the entire project
subprojects.forEach {it -> subprojects.forEach {it ->
// Enable preview features for the entire project
it.tasks.withType(JavaCompile).configureEach { it.tasks.withType(JavaCompile).configureEach {
options.compilerArgs += ['--enable-preview'] options.compilerArgs += ['--enable-preview']
} }
@ -22,6 +22,12 @@ subprojects.forEach {it ->
it.tasks.withType(Test).configureEach { it.tasks.withType(Test).configureEach {
jvmArgs += ['--enable-preview'] jvmArgs += ['--enable-preview']
} }
// Enable reproducible builds for the entire project
it.tasks.withType(AbstractArchiveTask).configureEach {
preserveFileTimestamps = false
reproducibleFileOrder = true
}
} }
allprojects { allprojects {