如何在CI/CD中始终使用依赖项的最新发布版本的Maven配置。

huangapple go评论89阅读模式
英文:

Maven how to always use the LATEST release of a depdenecy in CI/CD

问题

对于我们的项目,我们依赖于另一个内部库,而这个库发布非常频繁。
在父应用程序中,我们希望始终使用这个依赖项的最新版本。
使用Maven 3.x,我在pom文件中执行了以下操作:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>versions-maven-plugin</artifactId>
    <version>${versions-maven-plugin.version}</version>
    <configuration>
        <includes>
            <include>abc.def.xyz:exmaple-dep</include>
        </includes>
    </configuration>
</plugin>

但是当我使用Maven来获取最新版本时,它获取了所有依赖项的最新版本。
我使用以下命令测试了这种行为:

mvn versions:display-dependency-updates -Dincludes=abc.def.xyz:exmaple-dep

解决方案是让versions-maven-plugin仅获取给定依赖项的最新版本。

英文:

For our project, we have a dependency on another internal library and this library has very very frequent releases.
In the parent application, we want to always use the latest version of this dependency.
With Maven 3.x, I did the following in the pom file

&lt;plugin&gt;
                &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                &lt;artifactId&gt;versions-maven-plugin&lt;/artifactId&gt;
                &lt;version&gt;${versions-maven-plugin.version}&lt;/version&gt;
                &lt;configuration&gt;
                    &lt;includes&gt;
                        &lt;include&gt;abc.def.xyz:exmaple-dep&lt;/include&gt;
                    &lt;/includes&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;

But when I use the maven to fetch the latest versions, it is fetching latest versions of all dependencies.
I tested this behaviour with the below command:

mvn versions:display-dependency-updates -Dincludes=abc.def.xyz:exmaple-dep

What would be the solution that versions-maven-plugin fetches the latest version only of the given dependency.

答案1

得分: 1

目标 versions:display-dependency-updates 没有 include 参数,但 versions:use-latest-versions 有。

如果语法无效,请使用代替的语法 abc.def.xyz:exmaple-dep:*:*:*

英文:

The goal versions:display-dependency-updates does not have an include parameter, but versions:use-latest-versions has.

If the syntax does not work, use abc.def.xyz:exmaple-dep:*:*:* instead.

huangapple
  • 本文由 发表于 2020年7月31日 21:46:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/63193065.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定