为什么Maven不能识别使用Jenkins的父体pom的自定义repo?

问题描述 投票:1回答:1

我有以下的父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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>...</groupId>
    <artifactId>core</artifactId>
    <packaging>pom</packaging>
    <version>0.0.12-SNAPSHOT</version>
    ...
</project>

它安装到一个自定义的工件库中。下一步我想使用它,所以我创建了一个像这样的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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>...</groupId>
    <artifactId>child</artifactId>
    <packaging>jar</packaging>
    <version>0.0.1-SNAPSHOT</version>
    ...
    <parent>
        <groupId>...</groupId>
        <artifactId>core</artifactId>
        <version>0.0.11</version>
    </parent>
</project>

所有的仓库信息都存储在settings.xml中。然而,当jenkins运行时... ...

mvn -f pom.xml --batch-mode help:effective-pom -Drevision=DERIVED -Doutput=effectivePom.xml -s ./build/java/settings.xml

它没有使用自定义仓库,而是使用默认仓库。我遗漏了什么?是否需要运行一些预步骤来配置父版本的仓库?

设置.xml

<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
    <servers>
        <server>
            <id>CUSTOM</id>
            <username>...</username>
            <password>...</password>
        </server>
        <server>
            <id>CUSTOM-SNAPSHOT</id>
            <username>...</username>
            <password>...</password>
        </server>
    </servers>
    <profiles>
        <profile>
            <id>mine</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <pluginRepositories>
                ...
            </pluginRepositories>
            <repositories>
                <repository>
                    <id>CUSTOM-SNAPSHOT</id>
                    <url>...</url>
                    <releases><enabled>false</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </repository>
                <repository>
                    <id>CUSTOM</id>
                    <url>...</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>false</enabled></snapshots>
                </repository>
                <repository>
                    <id>main</id>
                    <url>...</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>false</enabled></snapshots>
                </repository>
            </repositories>
        </profile>
    </profiles>
    <activeProfiles>
        <!-- make the profile active all the time -->
        <activeProfile>mine</activeProfile>
    </activeProfiles>
</settings>

我还跑 cat build/java/settings.xml 上的jules作业,文件显示为预期。

更新2

我试着用-X参数来运行maven,看看事情的来龙去脉,结果发现了一些问题......

[DEBUG] Using mirror main (...main url) for custom (... custom url).

看来某个地方的镜像设置不正确,如何删除?我仔细检查了我的代码,没有看到任何地方有镜像。

maven jenkins artifactory
1个回答
0
投票

问题似乎是在Jenkins服务器上安装了一个默认的镜像(在settings.xml或任何它使用的东西)。关键是 -X 选项,这显示了镜像映射。所以为了解决这个问题,我覆盖了这个选项,删除了自定义的repo... ...

<mirrors>
    <mirror>
        <!--This sends everything else to /jpmc-public -->
        <id>main</id>
        <mirrorOf>*,!CUSTOM</mirrorOf>
        <url>... main url</url>
    </mirror>
</mirrors>

我只在远程设置.xml中添加了这个选项,因为这会破坏本地的设置。然而,这似乎已经解决了这个问题。

© www.soinside.com 2019 - 2024. All rights reserved.