Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I have multiple local repository for maven?

Tags:

maven

In maven settings, there is an entity which refers the local repository:

<localRepository>~/.m2/repository</localRepository>

When I add another one, like this:

<localRepository>~/another/place</localRepository>

it raises Duplicated tag error.

Can I have multiple local repository or maybe add another direcotry to the local repository?

EDIT This idea seems a possible answer, too:

mvn -Dmaven.repo.local=/path/to/repo
like image 321
AmirSojoodi Avatar asked Jul 22 '15 13:07

AmirSojoodi


1 Answers

Yes you can have and you can do it in your POM.xml itself. Below is an example.

<project>
...
  <repositories>
    <repository>
      <id>firstrepo</id>
      <name>repo</name>
      <url>http://myrepo.my</url>
    </repository>
    <repository>
      <id>secondrepo</id>
      <name>repo2</name>
      <url>http://myrepo.yours</url>
    </repository>
  </repositories>
...
</project>

Second Method by creating profile in your settings.xml

For multiple local repositories you can have multiple settings.xml file. In the command line specify alternate path using mvn -Dmaven.repo.local=/path/to/repo For more information you can check this link. Hope it helps.

like image 197
sTg Avatar answered Sep 20 '22 11:09

sTg