Local Cache vs Forced Updates: Choosing a Reproducible CI Strategy for Maven Builds
0 reputation · 03 May 2020, 12:52 UTC
Context
A multi-module Maven project runs in a CI pipeline where build reproducibility is a hard requirement. The team currently uses the local repository cache for speed but has observed occasional version drift when snapshot artifacts are updated in the remote repository between pipeline stages.
Constraint
The pipeline must complete within a strict time budget, so adding the -U flag to every build increases latency and load on the internal artifact repository. However, skipping -U risks building against stale snapshots, which breaks the reproducibility guarantee.
Decision Point
Maven’s default caching behavior favors performance, while -U favors correctness for moving targets. The dependencyManagement section can pin release versions, but snapshots remain mutable by design.
Which approach better satisfies a strict reproducibility requirement without exceeding the pipeline time budget?
- Run standard cached builds and rely on
dependencyManagementplus version locking for releases, accepting snapshot risk. - Enable
-Uselectively for snapshot-heavy modules only. - Adopt a hybrid strategy: cached builds for PR validation, forced updates for release candidates.