Stacker
Stacker

Reputation: 167

Maven not pulling dependency from correct repository

I have 3 repositories setup in our Nexus Repository manager

COMPANY_maven-proxy -> proxies https://repo1.maven.org/maven2/
COMPANY_maven-redhat-proxy -> proxies https://maven.repository.redhat.com/ga/
3rd-Party-Tools -> our companies homegrown 3rdParty dependencies 

When I run the mvn install command it pulls everything I'm looking for from each of these repositories (the dependency itself and the transitive dependencies). All except for one!

org.jboss.seam.integration:jboss-seam-int-jbossas:pom:7.0.0.GA 

This dependency lives in the Redhat maven repository:

<dependency>
   <groupId>org.jboss.seam.integration</groupId>
   <artifactId>jboss-seam-int-jbossas</artifactId>
   <version>7.0.0.GA</version>
   <type>pom</type>
</dependency>

For whatever reason, this one dependency is looking under the COMPANY_maven-proxy repository instead of the COMPANY_maven-redhat-proxy repository.

Here's what I have for my settings.xml:

<?xml version="1.0" encoding="UTF-8"?>
<settings>
    <mirrors>
    <mirror>
      <!--This sends everything to COMPANY_maven-proxy that isn't in COMPANY_maven-redhat-proxy -->
      <id>COMPANY_maven-proxy</id>
      <url>http://FQDN:8081/nexus/repository/COMPANY_maven-proxy/</url>
      <mirrorOf>*,!COMPANY_maven-redhat-proxy</mirrorOf>
    </mirror>
    <mirror>
      <!-- This sends everything to COMPANY_maven-redhat-proxy that isn't in COMPANY_maven-proxy -->
      <id>COMPANY_maven-redhat-proxy</id>
      <url>http://FQDN:8081/nexus/repository/COMPANY_maven-redhat-proxy/</url>
      <mirrorOf>*,!COMPANY_maven-proxy</mirrorOf>
    </mirror>
    <mirror>
      <!--This sends everything else to 3rd-Party-Tools -->
      <id>3rd-Party-Tools</id>
      <url>http://FQDN:8081/nexus/repository/3rd-Party-Tools/</url>
      <mirrorOf>!COMPANY_maven-proxy,!COMPANY_maven-redhat-proxy</mirrorOf>
    </mirror>
  </mirrors>
</settings>

Here's the error I get:

Failed to collect dependencies at org.jboss.seam.integration:jboss-seam-int- 
jbossas:pom:7.0.0.GA: Failed to read artifact descriptor for org.jboss.seam.integration:jboss- 
seam-int-jbossas:pom:7.0.0.GA: Could not find artifact org.jboss.seam.integration:jboss-seam- 
int:pom:7.0.0.GA in COMPANY_maven-proxy (http://FQDN:8081/nexus/repository/COMPANY_maven-proxy/) -> [Help 1]

I've tried multiple combination's within the <mirrorOf> tag but nothing has worked. I've even put this transitive depency in my pom under <dependencies> and/or <dependencyManagement>.

Any help on this would be appreciated!

Thanks!

Upvotes: 1

Views: 1573

Answers (1)

Rusi Popov
Rusi Popov

Reputation: 404

The mirrors are for already existing repositories declared. In your settings.xml you do not have repositories listed, but the default Maven Central. Thus it makes sense to define just a mirror of Maven Central, redirecting to the company's Nexus repo. with a rare trick, one could register a mirror for any external repos, for example:

    <mirror>
      <id>public</id>
      <mirrorOf>central</mirrorOf>
      <name>Let the default Maven Central repository is resolved in the local Nexus' public repository</name>
      <url>http://FQDN:8081/nexus/repository/COMPANY_maven-proxy/</url>
    </mirror>

Any mirror from your example should be registered in the pom.xml as repositories.

Edited:

  • removed the second ("other") mirror, as the example was adapted from a case where the repository manager to direct to runs at localhost.

Upvotes: 2

Related Questions