mavenmirror

maven - mirror depending on project


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?


Solution

  • 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.