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