7

While I know that mvn install -U is for update-snapshots and that it updates everything from the remote repository as seen from the build logs, I am not able to understand which part would it force update. Because it is my understanding that even mvn install would pick things from the remote repository even when it is present in the local repository (except is cases when the internal timer used by maven to update the snapshot expires).

Is the above description accurate or have I misunderstood the use of update-snapshots?

Naveen Dennis
  • 1,223
  • 3
  • 24
  • 39
  • Also see http://stackoverflow.com/questions/29020716/maven-what-does-u-update-snapshots-really-do/29020990#29020990 – Alexander Mar 31 '15 at 13:50

2 Answers2

7

Maven is checking for update of SNAPSHOT artifacts base on an interval. By default it is checked daily. Which means, if in the morning you got an update in SNAPSHOT, and another version is available in the afternoon in the remote repository, you will not be able to get it until tomorrow.

-U options force checking for SNAPSHOT updates even the update interval is not reached.

One note to add, although the description for -U in mvn -h is

Forces a check for updated releases and snapshots on remote repositories

base on my previous experience, releases are never checked for updates. i.e. We will always rely on whatever we previous retrieved for releases.

Adrian Shum
  • 38,812
  • 10
  • 83
  • 131
  • I don't know which version you are using but in 3.2.5 they changed the description to "Forces a check for missing releases and updated snapshots on remote repositories" (which is more accurate). – Joachim Rohde Mar 31 '15 at 09:29
  • @JoachimRohde I have been using Maven 2.0.x to 3.0.5 and I found the message misleading for long. Good to know that message is fixed in later version :) – Adrian Shum Apr 01 '15 at 04:22
  • Good explanation,it helps a lot. – jacky May 04 '18 at 03:24
-1

By default, maven checks for the updated copy of the SNAPSHOT artifacts i.e., fetches from remote repository for SNAPSHOT version of dependent artifacts (e.g 1.0-SNAPSHOT). This option forces Maven to check all snapshots in a remote repository and update your local repository if it’s out of date.

Balaji Katika
  • 2,835
  • 2
  • 21
  • 19