gpt4 book ai didi

maven-2 - Maven 中的版本传播

转载 作者:行者123 更新时间:2023-12-04 19:21:29 25 4
gpt4 key购买 nike

我有一个多模块 maven 项目,我想以这样一种方式使用版本,即开发人员只需触摸根项目 pom 即可更改所有模块的版本。

例如

ProjA 包含

  • 模块1
  • 模块2
  • 模块3

  • 所有模块都包含它们自己的 Pom,并以 ProjA 的 pom 作为其父模块。运行构建后,我会为每个模块创建一个 jar。现在为了构建一个更新版本的 ProjA,我只需要更改 ProjA 的 pom 的版本,并且模块的所有 pom 都应该从父级获取这个新版本。如果我在所有模块的 pom.xml 中对父版本进行硬编码,这将有效。但这也将迫使我为父 pom 中的每个版本更改更新所有模块的 pom,这违背了它的目的。
    有没有办法避免这种情况并仍然实现规定的行为?

    最佳答案

    使用 Maven Versions Plugin及其 versions:update-child-modules 目标:

    • versions:update-child-modules updates the parent section of the child modules of a project so the version matches the version of the current project. For example, if you have an aggregator pom that is also the parent for the projects that it aggregates and the children and parent versions get out of sync, this mojo can help fix the versions of the child modules. (Note you may need to invoke Maven with the -N option in order to run this goal if your project is broken so badly that it cannot build because of the version mis-match).

    关于maven-2 - Maven 中的版本传播,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3131710/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com