Naveen Dennis
Naveen Dennis

Reputation: 1223

What is the difference between mvn install -U and mvn install?

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?

Upvotes: 7

Views: 7487

Answers (2)

Adrian Shum
Adrian Shum

Reputation: 40036

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.

Upvotes: 7

Balaji Katika
Balaji Katika

Reputation: 3005

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.

Upvotes: -1

Related Questions