Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "http://central" mean in my Maven settings.xml?

Tags:

maven

I've been copying "sample" settings.xml files for ages now, and almost all of them seem to include a repository with the URL http://central. This bugs me, because of course there could actually be a machine on the local domain called "central", so this is a valid URN, but it also must (might?) have some special meaning to Maven.

Is it just shorthand that's commonly used, but the actual URL is ignored? Could I replace it with something else, or remove it entirely? Is it documented anywhere?

If it matters, I develop on a corporate network that has an internal iBiblio mirror, that acts as "central" for us.

like image 798
Coderer Avatar asked Apr 23 '13 08:04

Coderer


People also ask

How do I stop maven download from Central?

The simplest way is to use the -o parameter which tells maven to run in offline mode.

What is Maven central repository?

Introduction to Maven Central Repository. Maven repository is a directory where all the dependencies such as jars, library files, plugins, or other artifacts that will be required by the projects are stored.

What is default maven settings xml?

Maven's default settings. xml is a template with comments and examples so you can quickly tweak it to match your needs. Here is an overview of the top elements under settings : <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

Which settings xml does Maven use?

Maven always uses either one or two settings files. The global settings defined in ( ${M2_HOME}/conf/settings. xml ) is always required. The user settings file (defined in ${user.


2 Answers

AFAIK, it is a bogus URL which mentions at Configure Maven to Download from Nexus as the following example: -

<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>

The nexus profile is configured to download from the central repository with a bogus URL of http://central.

This URL is overridden by the mirror setting in the same settings.xml file to point to the URL of your single Nexus group. The nexus group is then listed as an active profile in the activeProfiles element.

I hope this may help.

like image 122
Charlee Chitsuk Avatar answered Oct 17 '22 03:10

Charlee Chitsuk


We also used exactly this sample config, even with the same comments for about 15(!) years without any problems. For maven builds it does not matter, as always nexus is requested for any dependencies.

But today I tried to built a project with a combined ant+maven build which failed to get dependencies via artifact:remoteRepository Task from central Repo.

The solution was to fix the "url" tag in the central repo: https://repo.maven.apache.org/maven2

So it looks like it doesn't matter in most cases, but to avoid any corner cases, always use the right url.

like image 43
Horst Krause Avatar answered Oct 17 '22 04:10

Horst Krause