Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How exactly mvn -U works?

Tags:

maven

maven-3

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" 
like image 708
Johnny Avatar asked Oct 06 '14 21:10

Johnny


People also ask

How does the Maven work?

Maven uses a declarative approach, where the project structure and contents are described, rather then the task-based approach used in Ant or in traditional make files, for example. This helps enforce company-wide development standards and reduces the time needed to write and maintain build scripts.

What does the mvn command do?

mvn package: Creates JAR or WAR file for the project to convert it into a distributable format. mvn install: Deploys the packaged JAR/ WAR file to the local repository. mvn deploy: Copies the packaged JAR/ WAR file to the remote repository after compiling, running tests and building the project.

How does Maven work with dependencies?

Dependencies are external JAR files (Java libraries) that your project uses. If the dependencies are not found in the local Maven repository, Maven downloads them from a central Maven repository and puts them in your local repository.

What is Maven concept?

Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information. Using maven we can build and manage any Java based project.


1 Answers

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.

like image 101
Eugene Kuleshov Avatar answered Oct 03 '22 00:10

Eugene Kuleshov