49

When I define an updatePolicy in my maven settings it tells maven how often snapshot artifacts shall be downloaded.

If I set it to always it of course downloads every time all snapshots.

I was wondering what happens if I set it to the default value daily or another longer peroid.

Does maven still check whether a new version of the snapshot is available and if so, does it download it although the policy says daily ?

I'm looking for the correct settings to avoid redundant downloads and not to miss a newer snapshot out there.

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
Emerson
  • 1,327
  • 2
  • 15
  • 24

1 Answers1

78

I was wondering what happens if I set it to the default value daily or another longer period.

The Repository - SNAPSHOT Handling explains it maybe better than the POM reference:

Each repository in the project has its own update policy:

  • always - always check when Maven is started for newer versions of snapshots
  • never - never check for newer remote versions. Once off manual updates can be performed.
  • daily (default) - check on the first run of the day (local time)
  • interval:XXX - check every XXX minutes

I don't think there is anything to add (except maybe that check != download).

Does maven still check whether a new version of the snapshot is available and if so, does it download it although the policy says daily ?

Well, no, why would it?

I'm looking for the correct settings to avoid redundant downloads and not to miss a newer snapshot out there.

Use always if you always want Maven to download a newer version of snapshots, if available (Maven will always check the remote repository but only download if the version is newer).

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • 1
    Thanks Pascal. I wasnt sure about the difference of checking vs downloading. So for my continuous build I keep the setting to always – Emerson Sep 28 '10 at 07:08
  • 1
    The first link is very old and refers to a ``. The tag is actually `` as in: daily – Ed Randall Jun 12 '17 at 14:42
  • Good answer - `always` is the safest policy. As other said, it won't download wastefully, only when a new version becomes available. If you are using internal depenencies and writing SNAPSHOTS to an artifactory, then you probably want the latest one as soon as it's available! – Adam Hughes Sep 22 '22 at 18:45