Skip to content
Latchkey

Maven stale SNAPSHOT not updated (updatePolicy) in CI

Maven did not re-download a -SNAPSHOT because the repository's updatePolicy (default daily) says the cached copy is still current. CI then compiles against an out-of-date snapshot and may fail with a missing symbol that the newer snapshot actually added.

What this error means

A build that depends on a freshly published -SNAPSHOT fails to compile (cannot find a new method/class), or resolves an older snapshot than expected. Adding -U makes it pass.

mvn output
[INFO] Using locally cached org.example:lib:1.0.0-SNAPSHOT (updatePolicy: daily, not yet stale)
[ERROR] symbol:   method newApi()
[ERROR] location: class org.example.Lib
[ERROR] cannot find symbol -> [Help 1]

Common causes

updatePolicy keeps the cached snapshot

The default daily policy means Maven only checks for a new snapshot once a day, so a snapshot published minutes ago is not fetched.

A warm .m2 cache hides the newer snapshot

A cached .m2 from a previous run holds an older snapshot, and the policy does not force a refresh.

How to fix it

Force snapshot updates with -U

Pass -U so Maven re-checks remote snapshots regardless of the update policy.

Terminal
mvn -B -U verify

Set updatePolicy to always for snapshots

For repositories that publish frequent snapshots, set the snapshot update policy in settings.xml.

~/.m2/settings.xml
<snapshots>
  <enabled>true</enabled>
  <updatePolicy>always</updatePolicy>
</snapshots>

How to prevent it

  • Build dependent jobs with -U when consuming fresh snapshots.
  • Set updatePolicy=always for snapshot repositories in CI.
  • Prefer released versions over snapshots for reproducible builds.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →