Enda Farrell
Enda Farrell

Reputation: 898

Why is my POM's repository not being checked for artifacts?

I have a dependency on a jar supplied by a Nexus instance that isn't our department's repository. We don't (yet) want to update our Nexus to mirror the other repository, nor to change our (shared) settings.xml so I added the repository to our POM:

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.company.department</groupId>
    <artifactId>simple-sample-app</artifactId>
    <packaging>war</packaging>
    <version>0.1</version>
    <name>simple-sample-app Maven Webapp</name>
    <repositories>
        <repository>
            <id>other-department</id>
            <name>other-department.company.com</name>
            <url>http://other-department.company.com/content/repositories/releases/</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
    ...
</project>

However: the mvn builds are failing as the <id>other-department</id> repository is not being checked. What's not being set properly?

EDIT: here's my settings.xml

<settings>
    <offline>false</offline>
    <proxies>
        <proxy>
            <active>false</active>
            <host>internal-proxy.company.com</host>
            <port>8080</port>
            <nonProxyHosts>company.com</nonProxyHosts>
        </proxy>
    </proxies>
    <servers>
        <server>
            <id>releases</id>
            <username>deployment</username>
            <password>deploy</password>
        </server>
        <server>
            <id>snapshots</id>
            <username>deployment</username>
            <password>deploy</password>
        </server>
        <server>
            <id>site</id>
            <username>sitemanager</username>
            <password>sitemanager</password>
        </server>
    </servers>
    <mirrors>
        <mirror>
            <id>department-nexus-public-snapshots</id>
            <url>http://nexus.department.company.com/nexus/content/groups/public-snapshots</url>
            <mirrorOf>public-snapshots</mirrorOf>
        </mirror>
        <mirror>
            <id>department-nexus-public</id>
            <url>http://nexus.department.company.com/nexus/content/groups/public</url>
            <mirrorOf>external:*</mirrorOf>
        </mirror>
    </mirrors>

    <profiles>
        <profile>
            <id>development</id>
            <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>

        <profile>
            <id>public-snapshots</id>
            <repositories>
                <repository>
                    <id>public-snapshots</id>
                    <url>http://public-snapshots</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>public-snapshots</id>
                    <url>http://public-snapshots</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>

    <activeProfiles>
        <activeProfile>development</activeProfile>
        <activeProfile>public-snapshots</activeProfile>
    </activeProfiles>
</settings>

Upvotes: 2

Views: 803

Answers (1)

Enda Farrell
Enda Farrell

Reputation: 898

With thanks to Stefan H and @khmarbaise. The problem was in the mirror entries.

My old settings.xml had these mirror entries:

<settings>
  ...
  <mirrors>
    <mirror>
      <id>department-nexus-public-snapshots</id>
      <url>http://nexus.department.company.com/nexus/content/groups/public-snapshots</url>
      <mirrorOf>public-snapshots</mirrorOf>
    </mirror>
    <mirror>
      <id>department-nexus-public</id>
      <url>http://nexus.department.company.com/nexus/content/groups/public</url>
      <mirrorOf>external:*</mirrorOf>
    </mirror>
  </mirrors>
  ...
</settings>

The issue was that <mirrorOf>external:*</mirrorOf> was kicking in and effectively blocking the POM's repo. Here's the fix:

<settings>
  ...
  <mirrors>
    <mirror>
      <id>department-nexus-public-snapshots</id>
      <url>http://nexus.department.company.com/nexus/content/groups/public-snapshots</url>
      <mirrorOf>public-snapshots</mirrorOf>
    </mirror>
    <mirror>
      <id>department-nexus-public</id>
      <url>http://nexus.department.company.com/nexus/content/groups/public</url>
      <mirrorOf>external:*,!other-department</mirrorOf>
    </mirror>
  </mirrors>
  ...
</settings>

Now our department-nexus-public entry is not used only for everything: the other-department (the ID of the repo from the POM) can be checked too.

Now my POM's repo is being checked for artifacts.

Upvotes: 1

Related Questions