1

I am running mvn dependency:list-repositories in order to find out what repositories is maven actually considering and their order (I need this to troubleshoot my settings.xml configuration).

For a bigger project that does not use any <repository> tags in its pom.xml files (parent and child modules) I am getting much more repositories than I expected. I was expecting to get only Maven central repository but I get:

[INFO] Repositories used by this build:
[INFO]        id: sonatype-nexus-snapshots
      url: https://oss.sonatype.org/content/repositories/snapshots
   layout: default
snapshots: [enabled => true, update => daily]
 releases: [enabled => false, update => daily]

[INFO]        id: apache.snapshots
      url: http://repository.apache.org/snapshots
   layout: default
snapshots: [enabled => true, update => daily]
 releases: [enabled => false, update => daily]

[INFO]        id: netbeans
      url: http://bits.netbeans.org/nexus/content/groups/netbeans
   layout: default
snapshots: [enabled => false, update => daily]
 releases: [enabled => true, update => daily]

[INFO]        id: spring-libs-snapshot
      url: https://repo.spring.io/libs-snapshot
   layout: default
snapshots: [enabled => true, update => daily]
 releases: [enabled => true, update => daily]

[INFO]        id: apache.snapshots
      url: https://repository.apache.org/snapshots
   layout: default
snapshots: [enabled => true, update => daily]
 releases: [enabled => false, update => daily]

[INFO]        id: spring-libs-release
      url: https://repo.spring.io/libs-release
   layout: default
snapshots: [enabled => true, update => daily]
 releases: [enabled => true, update => daily]

[INFO]        id: central
      url: https://repo.maven.apache.org/maven2
   layout: default
snapshots: [enabled => false, update => daily]
 releases: [enabled => true, update => daily]

I searched where the super pom could be but did not find an absolute answer for it. I still looked in the location pointed by:

But I never see anything else but:

<repositories>
    <repository>
        <id>central</id>
        <name>Maven Repository Switchboard</name>
        <layout>default</layout>
        <url>http://repo1.maven.org/maven2</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

So, where are all these repositories configured or who configures/implies them automatically?

Gabriel Petrovay
  • 20,476
  • 22
  • 97
  • 168
  • There are parents which configure that or you are using a `settings.xml` file where things like this can be configured as well... – khmarbaise Apr 07 '20 at 22:36
  • None of my `pom.xml` files and neither `settings.xml` are defining these repositories. The pom files only use `...`. Removing some dependencies, I can see the list returned by `mvn dependency:list-repositories` becoming smaller. So my fear is that `dependency:list-repositories` is not doing what I was expecting: give me all the repositories that are visible for my POM files. I think it returns all the repos configures in the entire dependency tree (which is not useful for my use case: troubleshooting ``). – Gabriel Petrovay Apr 07 '20 at 23:38

1 Answers1

1

The solution for me was actually the command mvn help:evaluate and then, when prompted, asking for the value of ${project.repositories}. I found this in this SO answer (in this question the user wanted to get a list of default repositories, while I wanted to get the list of actual configured repositories).

...
[INFO] Enter the Maven expression i.e. ${project.groupId} or 0 to exit?:
${project.repositories}

The result is the actual list of repositories that are visible for the POM file:

<repositories>
  <repository>
    <id>confluent</id>
    <url>http://packages.confluent.io/maven/</url>
    <layout>default</layout>
  </repository>
  <repository>
    <id>central</id>
    <name>Central Repository</name>
    <url>https://repo.maven.apache.org/maven2</url>
    <layout>default</layout>
    <location>
      <lineNumber>27</lineNumber>
      <columnNumber>17</columnNumber>
      <source>
        <modelId>org.apache.maven:maven-model-builder:3.6.3:super-pom</modelId>
        <location>jar:file:/usr/local/Cellar/maven/3.6.3/libexec/lib/maven-model-builder-3.6.3.jar!/org/apache/maven/model/pom-4.0.0.xml</location>
      </source>
    </location>
    <idLocation>
      <lineNumber>28</lineNumber>
      <columnNumber>11</columnNumber>
      <source reference="../../location/source"/>
    </idLocation>
    <nameLocation>
      <lineNumber>29</lineNumber>
      <columnNumber>13</columnNumber>
      <source reference="../../location/source"/>
    </nameLocation>
    <urlLocation>
      <lineNumber>30</lineNumber>
      <columnNumber>12</columnNumber>
      <source reference="../../location/source"/>
    </urlLocation>
    <layoutLocation>
      <lineNumber>31</lineNumber>
      <columnNumber>15</columnNumber>
      <source reference="../../location/source"/>
    </layoutLocation>
    <snapshots>
      <enabled>false</enabled>
      <location>
        <lineNumber>32</lineNumber>
        <columnNumber>18</columnNumber>
        <source reference="../../../location/source"/>
      </location>
      <enabledLocation>
        <lineNumber>33</lineNumber>
        <columnNumber>18</columnNumber>
        <source reference="../../../location/source"/>
      </enabledLocation>
    </snapshots>
  </repository>
</repositories>
Gabriel Petrovay
  • 20,476
  • 22
  • 97
  • 168