【问题标题】:Update all versions in maven更新maven中的所有版本
【发布时间】:2023-03-06 14:27:01
【问题描述】:

我有一个 maven 项目,其中包含大量具有许多依赖项的子项目。现在我想将我的 pom 文件的所有版本更新为新版本并重建它们。例如,如果我有一个这样的 pom:

<parent>
    <groupId>theparentId</groupId>
    <artifactId>theParentArtifact</artifactId>
    <version>2.0</version>
    <relativePath>..</relativePath>
</parent>

<artifactId>eaics-wsa-model</artifactId>
<packaging>model</packaging>

<dependencies>
    <dependency>
        <groupId>groupId1</groupId>
        <artifactId>artifactId1</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>groupId2</groupId>
        <artifactId>artifactId2</artifactId>
        <version>2.0</version>
    </dependency>
    <dependency>
        <groupId>groupId3</groupId>
        <artifactId>artifactId3</artifactId>
        <version>1.3</version>
    </dependency>
  </dependencies>

我需要将 groupId1 到 groupId3 的依赖项更新为不存在 jet 的新版本。因为我还需要自己“创建”我的依赖项的新更新版本。

因为它们的 pom.xml 中的依赖项现在看起来像这样:

<groupId>groupId3</groupId>
<artifactId>artifactId3</artifactId>
<version>1.2</version>

如您所见,版本是 1.2 但需要更新到 1.3 才能使用依赖项。

那么有没有办法递归更新所有 pom(版本)?如果在 Java 中可以使用 MavenXpp3Reader 等,那就太好了。但是有没有更简单的方法呢?因为我担心在那之后我无法构建我的项目,因为我认为它们不会递归构建并且不会找到新的依赖版本。

【问题讨论】:

    标签: maven dependencies maven-3


    【解决方案1】:

    您可以使用versions-maven-plugin 更新所有 pom 的版本,这里有一些示例可以帮助您。

    【讨论】:

    • 感谢您的回答。但是他们会建立递归吗?我有很多项目依赖项,所以我需要先更新这些版本,在 maven 本地存储库中构建它们,然后更改依赖项的版本。
    • 如果所有模块都保持相同的版本,则它是递归的。对于您的特定场景,请查看此示例 mojo.codehaus.org/versions-maven-plugin/examples/set.html 您可以为每个项目设置。您可以使用自己的脚本来管理此流程设置,首先是所有依赖项,然后更新父项目设置属性
    猜你喜欢
    • 2016-04-10
    • 2021-10-27
    • 2015-08-04
    • 2015-09-24
    • 2015-04-01
    • 2018-04-28
    • 2013-10-02
    • 1970-01-01
    • 2018-09-02
    相关资源
    最近更新 更多