37

I want to know what exactly Maven do in the -U phase.

The argument ordering forced check for updates on remote repositories and if needed, updating the local maven repository with the updated dependencies used in our project.

As described:

-U --update-snapshots Forces a check for updated releases and snapshots on remote repositories

But, how exactly is this done? Is maven first of all downloading all the remote repositories and locally decides that they need to get updated, or, deciding without downloading them first? Is there some corner cases that should be known?

My Maven version is:

Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T16:51:42+03:00)
Maven home: /usr/local/Cellar/maven/3.2.2/libexec
Java version: 1.7.0_60, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.9.4", arch: "x86_64", family: "mac"
Johnny
  • 14,397
  • 15
  • 77
  • 118

1 Answers1

28

It is done only for the artifacts or dependencies referenced by your project.

The last check timestamp is stored within local artifact metadata (in your local Maven repository), so Maven can apply different strategies how often to check for updates based on that. The default update interval for snapshots is "daily".

Also see updatePolicy for remote repositories in Maven's settings.xml.

Eugene Kuleshov
  • 31,461
  • 5
  • 66
  • 67
  • Thanks Eugene. I'm still not sure how the checking for updates is done exactly. Can you please elaborate? – Johnny Oct 06 '14 at 21:33
  • 16
    The updates are checked by sending an http request for each artifact to remote Maven repository and then comparing the artifact timestamp with Maven's local artifact cache (aka local Maven repository). – Eugene Kuleshov Oct 07 '14 at 14:07
  • Great, thats exactly what i wanted to know. – Johnny Oct 07 '14 at 20:23