Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is meant by local repository and remote repository in Maven speak?

I am reading up Maven - The complete reference and came across this

Maven assumes that the parent POM is available from the local repository, or available in the parent directory (../pom.xml) of the current project. If neither location is valid this default behavior may be overridden via the relativePath element.

What exactly is meant by local and remote repository for a Maven installation and a project?

like image 666
Geek Avatar asked Dec 04 '12 06:12

Geek


People also ask

What is local and remote repository in Maven?

A repository in Maven holds build artifacts and dependencies of varying types. There are exactly two types of repositories: local and remote: the local repository is a directory on the computer where Maven runs. It caches remote downloads and contains temporary build artifacts that you have not yet released.

What is local repository and remote repository?

Local repositories reside on the computers of team members. In contrast, remote repositories are hosted on a server that is accessible for all team members - most likely on the internet or on a local network.

What is local repository in Maven?

Maven's local repository is a directory on the local machine that stores all the project artifacts. When we execute a Maven build, Maven automatically downloads all the dependency jars into the local repository. Usually, this directory is named .

What are the different types of Maven repositories?

There are 3 types of maven repository: Local Repository. Central Repository. Remote Repository.


2 Answers

A local repository is a local directory structure that caches artifacts downloaded from remote repositories, or those that are manually installed (eg from the command line option).

A remote repository is a web service (defined by a URL) that contains versioned artifacts. This might be as simple as an Apache server, or a full-blown Maven repository, such as Artifactory, that allows uploading, permissions based on a user directory, etc.

http://maven.apache.org/guides/introduction/introduction-to-repositories.html

like image 164
Andrew Alcock Avatar answered Sep 29 '22 08:09

Andrew Alcock


By default, Maven will source dependencies from, and install dependencies to, your local .m2 repository. This is a precedence rule, and your .m2 acts like a cache where Maven can source dependencies before downloading them remotely. You can bypass this behaviour like so: mvn -U ... (see mvn --help).

Your local .m2 can be found under C:\Users\{user}\.m2 on Windows, or /home/{user}/.m2 on Linux. If you do a mvn install, your project will be locally installed under the said .m2 repository.

A remote repository is a Maven repository, just like your local .m2 repository, hosted for you to source dependencies from, e.g. Maven Central.

like image 28
wulfgarpro Avatar answered Sep 29 '22 09:09

wulfgarpro