You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The spring-boot-maven-pluginrepackage goal does not set a reproducible timestamp.
The provided timestamp is used but offset with the local timezone of the developer.
A project wants to be reproducible and sets the project.build.outputTimestamp to a desired value with a clear timezone in it.
Then the spring-boot-maven-plugin is used to repackage the jar/war file.
The outputTimestamp by default uses the correct timestamp from project.build.outputTimestamp.
The problem is that the timestamp in final jar/war file has this timestamp expressed in the timezone of the local build system.
So someone in a different timezone can only reproduce the build if they are able to figure out the timezone of the original build system.
This makes the build needlessly hard to reproduce.
Reproduce
This mini project demonstrates this problem by building the same demo project twice in a docker image with a different timezone.
I expect the output to be in the specified timezone in the outputTimestamp
This will make the end result always be the same regardless of the timezone of the build system.
Actual output:
For different timezones the output file is different
scottfrederick
changed the title
[spring-boot-maven-plugin] outputTimestamp shifted using local timezone.
Maven plugin uses timezone-local timestamps when outputTimestamp is used
Mar 1, 2023
I did some digging and it seems the JarWriter gets to write a JarArchiveEntry which has the correct last modification timestamp (in epoch milliseconds).
Then during the actual writing in org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream a call is done to ZipUtil.toDosTime with a instance of Calendar which is initialized with Calendar.getInstance();.
This effectively means to fix this we have to change the default timezone of the application.
Based on that I put together the simplest fix I could think of in the mentioned merge request.
It doesn't produce reproducible artifacts. This issue was
reported earlier and (claimed to be) fixed in 2.7.10:
spring-projects/spring-boot#34424
Yet the fix doesn't help in our case.
Summary
The
spring-boot-maven-plugin
repackage
goal does not set a reproducible timestamp.The provided timestamp is used but offset with the local timezone of the developer.
A project wants to be reproducible and sets the
project.build.outputTimestamp
to a desired value with a clear timezone in it.Then the
spring-boot-maven-plugin
is used torepackage
the jar/war file.The
outputTimestamp
by default uses the correct timestamp fromproject.build.outputTimestamp
.The problem is that the timestamp in final jar/war file has this timestamp expressed in the timezone of the local build system.
So someone in a different timezone can only reproduce the build if they are able to figure out the timezone of the original build system.
This makes the build needlessly hard to reproduce.
Reproduce
This mini project demonstrates this problem by building the same demo project twice in a docker image with a different timezone.
https://github.com/nielsbasjes/BugreportSpringPluginTimezone
Expected
I expect the output to be in the specified timezone in the
outputTimestamp
This will make the end result always be the same regardless of the timezone of the build system.
Actual output:
For different timezones the output file is different
Snippets from diffoscope:
The content (all jar files and such) are identical
In timezone Europe/Amsterdam
In timezone Australia/Eucla
In timezone AU/Hawaii
The text was updated successfully, but these errors were encountered: