quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.36k stars 2.56k forks source link

Add new property `quarkus.build.timestamp` #41070

Open Eng-Fouad opened 4 weeks ago

Eng-Fouad commented 4 weeks ago

Description

Implementation ideas

Something similar to [BuildProperties::getTime](https://docs.spring.io/spring-boot/api/java/org/springframework/boot/info/BuildProperties.html#getTime()) in spring boot. The build information are stored at META-INF/build-info.properties by maven/gradle then read at runtime and constructed as a bean. The file META-INF/build-info.properties is registered for inclusion in native image.

gastaldi commented 4 weeks ago

Just a minor observation that storing the build timestamp inside the JAR would impact reproducible builds, but maybe we can make that information optional

maxandersen commented 3 weeks ago

Yeah - this seems counter to reproducible builds.

Must it be the actual time or is latest commit time sufficient?

Eng-Fouad commented 3 weeks ago

Must it be the actual time or is latest commit time sufficient?

The actual build time.

maxandersen commented 3 weeks ago

I don't have a good solution thus very much open for ideas that we need to find a way to at least have a toggle or behavior that avoids this being written as it does make it tricky for reproducible builds.

But instead of having a enabled true/false for every thing that could do this we should consider how this can be handled better/consistenly.

Like, actual build time for me is not something I think make sense to store by default inside the artifact - that fits better some external "build metadata" data. The latest sha/youngest commit timestamp from the build system would be something one could store more consistently and also what reproducible builds normally lean towards.

anyone know of patterns used elsewhere? global "try-make-repeatable-build-artifact" on/off switch that different extensions could honor (as best as they can and if not print warning or possibly fail if they know they can't?)

Eng-Fouad commented 3 weeks ago

Just for reference, spring boot supports reproducible builds by defaulting spring-boot-maven-plugin:build-info's time to project.build.outputTimestamp. See: https://github.com/spring-projects/spring-boot/pull/26221

maxandersen commented 3 weeks ago

That solves it for that single property but for maven specifically. how about for gradle and how about reaugmentation - there one would expect another build timestamp ?