2

我依赖于不是我们部门存储库的 Nexus 实例提供的 jar。我们(还)不想更新我们的 Nexus 以镜像另一个存储库,也不想更改我们的(共享)settings.xml所以我将存储库添加到我们的 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>

但是:由于未检查存储库,因此 mvn 构建失败<id>other-department</id>。什么设置不正确?

编辑:这是我的 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>
4

1 回答 1

1

感谢 Stefan H 和 @khmarbaise。问题出在镜像条目中。

我的旧 settings.xml 有这些镜像条目:

<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>

问题在于它<mirrorOf>external:*</mirrorOf>正在启动并有效地阻止了 POM 的回购。这是修复:

<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>

现在我们的department-nexus-public条目不仅仅用于所有内容:other-department也可以检查(来自 POM 的 repo 的 ID)。

现在我的 POM 的 repo 正在检查工件。

于 2012-07-24T12:03:36.283 回答