A Gradle or Maven build must be reproducible byte for byte. What do you do?
AdvancedScenarioBuilds, Artifacts, Nexus, SonarQube and Testing
Answer
Situation read → Timestamps and ordering make artifacts differ.
What I'd do →
- Set
project.build.outputTimestampin Maven (orpreserveFileTimestamps = falseandreproducibleFileOrder = truein Gradle archive tasks). - Pin the JDK and tool versions, build in a pinned container, and lock dependencies.
- Verify by building twice and comparing digests (
sha256sum) or usingdiffoscope.
Why → Reproducible builds let third parties verify that binaries match the source.
Interview tip → Mention SLSA and the verification step.
More on Builds, Artifacts, Nexus, SonarQube and Testing
A Maven project resolves dependencies from Maven Central on every build and a left-pad style outage would stop all builds.BeginnerYou must publish snapshot and release artifacts without overwriting a released version.IntermediateEvery merge to main should produce a unique semantic version automatically.IntermediateAn npm build is non-reproducible: different versions install on different days.BeginnerThe SonarQube quality gate must block merging PRs that add new bugs, vulnerabilities or uncovered code.IntermediateCoverage shows 0% in SonarQube although tests run in CI.Intermediate