Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

repository tag under distributionManagement vs repositories?

Tags:

maven

I see repository tag under parent element i.e distributionManagement and repositories. What's the difference ?

<distributionManagement>     <repository>         <id>...</id>         <name>...</name>         <url>...</url>     </repository> </distributionManagement>   <repositories>     <repository>         <id>...</id>         <name>...</name>         <layout>default</layout>         <url>...</url>     </repository> </repositories> 

My understanding repository element under distributionManagement element specifies where it will deploy the artifacts at the time of deployment. It will come into picture only while mvn deploy i.e deployment time not during mvn install i.e build time. Right?

repository element under repositories element specifies from where dependencies needs to be picked up. It will come into picture only while mvn install not during mvn deploy. Right?

like image 213
emilly Avatar asked Feb 10 '16 13:02

emilly


People also ask

What is distributionManagement tag in Maven?

From the POM reference: Where as the repositories element specifies in the POM the location and manner in which Maven may download remote artifacts for use by the current project, distributionManagement specifies where (and how) this project will get to a remote repository when it is deployed.

What is repository tag in POM XML?

What is a Maven Repository? In Maven terminology, a repository is a directory where all the project jars, library jar, plugins or any other project specific artifacts are stored and can be used by Maven easily.


1 Answers

You have it exactly right!

From the POM reference:

Where as the repositories element specifies in the POM the location and manner in which Maven may download remote artifacts for use by the current project, distributionManagement specifies where (and how) this project will get to a remote repository when it is deployed. The repository elements will be used for snapshot distribution if the snapshotRepository is not defined.

  • Repositories declared under the distributionManagement element will be used for deployment, i.e. when running mvn deploy.
  • The repositories element will be used for downloading dependencies of the project. The command is not necessarily mvn install but any command that requires Maven to fetch artifacts from a repository.
like image 174
Tunaki Avatar answered Sep 23 '22 17:09

Tunaki