Maven <mirror> tag, meaning of external:* parameter

1.7k views Asked by At
<settings>
  ...
  <mirrors>
    <mirror>
      <id>internal-repository</id>
      <name>Maven Repository Manager running on repo.mycompany.com</name>
      <url>http://repo.mycompany.com/proxy</url>
      <mirrorOf>external:*</mirrorOf>
    </mirror>
  </mirrors>
  ...
</settings>

The official documentation, about the meaning of the external:* parameter within a <mirrorOf> tag, says that:

matches all repositories except those using localhost or file based repositories. This is used in conjunction with a repository manager when you want to exclude redirecting repositories that are defined for Integration Testing.

Within this context, my question are:

  • What does it mean that a repository uses localhost?
  • What does it mean that repository is file-based?
1

There are 1 answers

0
Tunaki On BEST ANSWER
  • What does it mean that a repository uses localhost?

Simply that the host of the URL used in any repository declaration is not localhost or 127.0.0.1. For example, a repository whose URL is declared as:

<repository>
  <id>my-repo</id>
  <url>http://localhost:8080/repo</url> <!-- or http://127.0.0.1:8080/repo -->
</repository>

it will not be considered by the external:* mirror, because its host is localhost. This could be the case, for example, if you have an artifact manager hosted on the same machine, and you're working locally (so there is no need for a proxy).

  • What does it mean that repository is file-based?

That the protocol of the URL of the repository is file. For example, a repository whose URL is declared as:

<repository>
  <id>my-repo</id>
  <url>file:///C:\my-repo</url>
</repository>

would be a file-based repository. The artifacts will be searched inside the folder C:\my-repo, like if it were a usual remote repository. This is useful if you want to set-up a remote repository for testing purposes (i.e. no artifact managers, just working with folders, possibly on another drive). In this case, there is no need for a proxy as well, and external:* will not consider it.

For reference, the code for external:* performs exactly those checks.