Skip to content

Commit e41d80d

Browse files
committed
Use local variable instead of project's extra properties
1 parent 8747727 commit e41d80d

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

buildSrc/src/main/kotlin/build-metadata.gradle.kts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,20 @@ import java.time.OffsetDateTime
44
import java.time.ZoneOffset
55
import java.time.format.DateTimeFormatter
66

7-
val buildTimeAndDate: OffsetDateTime by extra {
8-
9-
// SOURCE_DATE_EPOCH is a UNIX timestamp for pinning build metadata against
10-
// in order to achieve reproducible builds
11-
//
12-
// More details - https://reproducible-builds.org/docs/source-date-epoch/
13-
7+
val buildTimeAndDate =
148
if (System.getenv().containsKey("SOURCE_DATE_EPOCH")) {
159

10+
// SOURCE_DATE_EPOCH is a UNIX timestamp for pinning build metadata against
11+
// in order to achieve reproducible builds
12+
//
13+
// More details - https://reproducible-builds.org/docs/source-date-epoch/
1614
val sourceDateEpoch = System.getenv("SOURCE_DATE_EPOCH").toLong()
1715

1816
Instant.ofEpochSecond(sourceDateEpoch).atOffset(ZoneOffset.UTC)
1917

2018
} else {
2119
OffsetDateTime.now()
2220
}
23-
}
2421

2522
val buildDate: String by extra { DateTimeFormatter.ISO_LOCAL_DATE.format(buildTimeAndDate) }
2623
val buildTime: String by extra { DateTimeFormatter.ofPattern("HH:mm:ss.SSSZ").format(buildTimeAndDate) }

0 commit comments

Comments
 (0)