Skip to content

Commit 08f6bad

Browse files
committed
reproducible builds: SOURCE_DATE_EPOCH support - Remove some non-determinism - closes #2547, by @gsantner
1 parent bef870d commit 08f6bad

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,10 @@ ext.getGitLastCommitMessage = providers.exec {
104104
static String getBuildDate() {
105105
final SimpleDateFormat RFC3339_LIKE = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'")
106106
RFC3339_LIKE.setTimeZone(TimeZone.getTimeZone("UTC"))
107-
return RFC3339_LIKE.format(new Date())
107+
Date buildDate = new Date()
108+
109+
// https://reproducible-builds.org/docs/source-date-epoch/
110+
try { buildDate = new Date(Long.parseLong(System.getenv('SOURCE_DATE_EPOCH')) * 1000) } catch(Exception ignore) {}
111+
112+
return RFC3339_LIKE.format(buildDate)
108113
}

0 commit comments

Comments
 (0)