12

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
AmirSojoodi
  • 1,080
  • 2
  • 12
  • 31
  • 1
    do you want to resolve artifacts from multiple repositories or split the local repositories you download artifacts into between maven versions or projects? – wemu Jul 22 '15 at 13:29
  • I want tor resolve artifacts from multiple repositories. – AmirSojoodi Jul 22 '15 at 13:35

1 Answers1

14

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.

Community
  • 1
  • 1
sTg
  • 4,313
  • 16
  • 68
  • 115