In light of the efforts of #8391 ... builds can be reproducible, however...
In Spring Boot 2.0.0.RC1 if you are using:
springBoot {
buildInfo()
}
In your build.gradle
file... the build jar files are not binary equal.
The plug-in includes the build.time
property and there isn't an obvious way to turn that off.
This is in the build/resources/main/META-INF/build-info.properties
file.
Possible suggestions for remedy: 1. Allow the timestamp to be set to the time of the VCS commit. 2. Allow the timestamp to be set to a "release time" fixed value. 3. Allow the timestamp to be null or omitted entirely.
Comment From: wilkinsona
You can remove unwanted properties from the auto-generated build-info.properties
file by post-processing it. The following example removes build.time
:
springBoot {
buildInfo {
doLast {
File propertiesFile = new File(destinationDir, 'build-info.properties')
Properties properties = new Properties()
propertiesFile.withInputStream { properties.load(it)}
properties.remove('build.time')
propertiesFile.withOutputStream { properties.store(it, 'UTF-8') }
}
}
}
Comment From: jzampieron
Thanks.
Comment From: schnapster
For people like me who just copypasta stuff from Github issues they stumble upon:
The above approach didn't work for me (Spring Boot v2.2.4). For some reason a timestamp was still written into the file, just as a comment at the top of the file.
This is what worked:
springBoot {
buildInfo {
properties {
time = null
}
}
}
You can also set it to something else than null as long as it is constant between reruns of the same code. For a bit more fancy usage, you could use a Gradle git plugin and fetch the timestamp from the last commit for example.