繁体   English   中英

当我刚刚更新项目的 pom 版本时,如何防止 Maven 从存储库下载工件

[英]How to prevent Maven from downloading artifacts from repository when I just update the pom version of my project

我使用 Maven 作为 CI 和 JFrog Artifactory 作为我自己的工件的存储库和缓存。 一切正常。 我正在使用 Jenkins 中的 Artifactory 插件来触发工件下载和上传。 我不知道如何处理以下用例。 我有一个多模块项目。 在我的 Settings.xml 中,我定义了一些快照、插件和发布存储库。 在我的本地工作区中,我升级了父项目及其子项目的 pom 版本。 然后我进行了本地全新安装。 它失败了,因为 Maven 试图从 Artifactory 下载我的项目的工件,它们当然不存在,因为我正在尝试创建项目的新版本。 如何处理这个用例? 如何配置我的 pom 或设置来做? 如何在 Jenkins 的 Artifactory 插件中以自由式的方式做到这一点?

我有这样的错误消息:

10:23:28 传输失败找不到元数据 com.xxx.xxxx.xxx:my-parent-project:3.0.0-SNAPSHOT/maven-metadata.xml in xxx 10:23:50 [无法解决] com.xxx.xxxx.xxx:subpoject1:[unknown-version] 的父 POM:找不到工件.....并且“parent.relativePath”指向错误的本地 POM @ 第 7 行,第 10 列*

======================================

父pom的pom配置

<modelVersion>4.0.0</modelVersion>
<groupId>com.xxx.xxx.xxx</groupId>
<artifactId>my-parent-project</artifactId>
<version>3.0.0-SNAPSHOT</version>
<packaging>pom</packaging>


<modules>
    <module>../subproject-1</module>
    <module>../subproject-2</module>
</modules>

====================================

子项目 1 的 pom 配置

    <artifactId>subproject-1</artifactId>

<parent>
    <groupId>com.xxx.xxx.xxx</groupId>
    <artifactId>my-parent-project</artifactId>
    <version>3.0.0-SNAPSHOT</version>
</parent>

=======================================

这是我的设置。xml 配置

<profile>
        <id>artifactory_profile</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <repositories>
            <repository>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
                <id>central</id>
                <name>libs-release</name>
                <url>http://xxxxxxxxxxxx:8081/artifactory/libs-release</url>
            </repository>
            <repository>
                <snapshots />
                <id>snapshots</id>
                <name>libs-snapshot</name>
                <url>http://xxxxxxxxxxxx:8081/artifactory/libs-snapshot</url>
            </repository>

            <repository>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
                <id>sing</id>
                <name>sing-virtual-repo</name>
                <url>http://xxxxxxxxxxxx:8081/artifactory/virtual-repo</url>
            </repository>               
        </repositories>

        <pluginRepositories>
            <pluginRepository>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
                <id>central</id>
                <name>plugins-release</name>
                <url>http://xxxxxxxxxxxx:8081/artifactory/plugins-release</url>
            </pluginRepository>
            <pluginRepository>
                <snapshots />
                <id>snapshots</id>
                <name>plugins-release</name>
                <url>http://xxxxxxxxxxxx:8081/artifactory/plugins-release</url>
            </pluginRepository>
        </pluginRepositories>
    </profile>

如果您在父 POM 上运行clean install ,那么所有内容都将正确创建。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM