Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the updatePolicy in maven really work?

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.

like image 780
Emerson Avatar asked Sep 27 '10 15:09

Emerson


People also ask

What is updatePolicy in Maven?

updatePolicy: This element specifies how often updates should attempt to occur. Maven will compare the local POM's timestamp (stored in a repository's maven-metadata file) to the remote. The choices are: always , daily (default), interval:X (where X is an integer in minutes) or never .

What argument do you pass to Maven in order to update snapshots from the remote repository?

Maven follows the repository's updatePolicy , which tells it how often (if ever) maven checks if a dependency has been updated (in the case of SNAPSHOT), or has become available, in the case of a released version.

What is Snapshotrepository in Maven?

SNAPSHOT is a special version that indicates a current development copy. Unlike regular versions, Maven checks for a new SNAPSHOT version in a remote repository for every build.

What is settings xml in Maven?

A Maven settings. xml file defines values that configure Maven execution in various ways. Most commonly, it is used to define a local repository location, alternate remote repository servers, and authentication information for private repositories.


1 Answers

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).

like image 69
Pascal Thivent Avatar answered Sep 23 '22 10:09

Pascal Thivent