Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shared Maven Repository across developers

Is there any way to avoid developers download all dependencies and have those dependencies located to shared locattion to all the developer and each developer working on project point to that location?

Can anyone explain with sample files and example?

like image 557
Pritesh Shah Avatar asked Jan 31 '13 10:01

Pritesh Shah


People also ask

What is Maven ICM 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.

What is m2 repository in Maven?

m2 folder is the default folder used by maven to store its: settings. xml file which specifies properties, like the central repository to download your dependencies, the location of the so-called localRepository. by default, the localRepository in which maven stores all the dependencies your project might need to run.

What are the different types of Maven repositories?

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

What is the difference between mirror and repository in Maven?

Mirror means a repository that is used as a passerelle/proxy to an other repository. When using a repository manager like Nexus, Artiafactory, Archiva... you dispose of one local entreprise repository wich proxifies remotes ones. So there is no need to declare too many repositories in your pom or setting.


2 Answers

Best is to go with one of the repository managers for maven. The main steps for the setup will be: - Install a central repository on an internal machine - Configure the central repository to proxy the repositories you need for your developers - Modify the developers maven settings to use the internal maven repository as mirror for everything (see here for details)

There are 3 well-known repository managers available:

  • Artifactory: http://www.jfrog.com/home/v_artifactory_opensource_overview
  • Apache archiva: http://archiva.apache.org/index.cgi
  • Sonatype Nexus: http://www.sonatype.org/nexus/

I favorite Artifactory - the installation and configuration took less than an hour. Now if a developer adds a new dependency to a maven project, the artifact will be downloaded from the original remote repository to the internal repository and will be made available. When the next developer needs the archive it will be downloaded from the internal repository - the access will be much faster.

like image 159
MrsTang Avatar answered Sep 23 '22 20:09

MrsTang


You can change local repository like this:

The location of your local repository can be changed in your user configuration. The default value is ${user.home}/.m2/repository/.

<settings>
  ...
  <localRepository>/path/to/local/repo/</localRepository>
  ...
</settings>

look this article

I think if you make shared folder and all other developers write path to this folder this can help.(but I didn't try this)

UPDATE

Using shared repo is bad idea. Sharing local repository between two or many users is not thread safe and may result in different errors.
So as many people mentioned here use Artifactory

like image 22
Aleksei Bulgak Avatar answered Sep 24 '22 20:09

Aleksei Bulgak