[Git][reproducible-builds/reproducible-website][master] Add Maven, Gradle, JDK and Groovy examples to SOURCE_DATE_EPOCH page.

Chris Lamb (@lamby) gitlab at salsa.debian.org
Mon Apr 8 10:13:30 UTC 2024


Chris Lamb pushed to branch master at Reproducible Builds / reproducible-website


Commits:
bfcbb9a2 by Chris Lamb at 2024-04-08T11:12:56+01:00
Add Maven, Gradle, JDK and Groovy examples to SOURCE_DATE_EPOCH page.

- - - - -


1 changed file:

- _docs/source-date-epoch.md


Changes:

=====================================
_docs/source-date-epoch.md
=====================================
@@ -344,6 +344,58 @@ let now = match env::var("SOURCE_DATE_EPOCH") {
 };
 ```
 
+### Maven
+
+Add the following property in the `pom.xml` file:
+
+```
+<properties>
+    <project.build.outputTimestamp>
+        ${env.SOURCE_DATE_EPOCH}
+    </project.build.outputTimestamp>
+</properties>
+```
+
+### Gradle
+
+Set the following properties for the Zip Task that creates the `.jar` file:
+
+```
+// Normalizes the ZIP and JAR archives
+tasks.withType(Zip) {
+   preserveFileTimestamps = false
+   reproducibleFileOrder = true
+}
+```
+
+### JDK
+
+Builds of OpenJDK version 19 or later [support the following new option](https://bugs.openjdk.org/browse/JDK-8276766) in the `jar` and `jmod` commands:
+
+```
+--date=TIMESTAMP
+   The timestamp in ISO-8601 extended offset date-time with optional
+   time-zone format, to use for the timestamp of the entries,
+   e.g. "2022-02-12T12:30:00-05:00".
+```
+
+### Groovy
+
+```groovy
+import java.time.Instant
+import java.time.temporal.ChronoUnit
+
+def buildInstant = Instant.now().truncatedTo(ChronoUnit.SECONDS)
+def sourceDateEpoch = System.getenv("SOURCE_DATE_EPOCH")
+if (sourceDateEpoch != null) {
+   def epochSeconds = Long.parseLong(sourceDateEpoch)
+   buildInstant = Instant.ofEpochSecond(epochSeconds)
+}
+// Creates the timestamp in UTC using the ISO 8601 extended format.
+def extendedTimestamp = buildInstant.toString()
+```
+
+
 ### Last-resort using faketime
 
 ''As a last resort to be avoided where possible'' (e.g. if the upstream tool is too hard to patch, or too time-consuming for you right now to patch, or if they are being uncooperative or unresponsive), package maintainers may try something like the following:



View it on GitLab: https://salsa.debian.org/reproducible-builds/reproducible-website/-/commit/bfcbb9a29feaa6df065091b01f57fb43ad71b257

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/reproducible-website/-/commit/bfcbb9a29feaa6df065091b01f57fb43ad71b257
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20240408/1e7329c6/attachment.htm>


More information about the rb-commits mailing list