Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven - mirror depending on project

Tags:

maven

mirror

I have a mirror for maven central setup like this in settings.xml:

<mirrors>
  <mirror>
    <id>artifactory-other</id>
    <mirrorOf>*</mirrorOf>
    <url>http://some.internal.site/artifactory/repo</url>
    <name>Artifactory</name>
  </mirror>
</mirrors>

But this server is accessible only from the internal network. When I'm at home and tinker with some side projects I need to access the real repositories. For now I just comment this mirror out, but it's cumbersome.

How can I make it automatic? Is it possible to define a profile with separate mirrors and automatically activated based on project path? Is there some simple solution?

like image 330
mabn Avatar asked Sep 08 '25 05:09

mabn


2 Answers

Unfortunately there is not an out-of-the-box solution with Maven. Usual i check in my settings.xml via git and having different branches for different networks like at work, home etc. The result is reduced to a simple

git checkout HOME

or

git checkout WORK

etc.

like image 98
khmarbaise Avatar answered Sep 10 '25 02:09

khmarbaise


The solution is not using mirror-any, but using specific repository declarations with dependencies pom cleanups. This way you'll be as protected from going to unauthorized repos as with mirror-any and you'll be able to declare profiles (work and home) with different servers in each of them.

like image 22
JBaruch Avatar answered Sep 10 '25 01:09

JBaruch