在Maven项目的模块中更新父版本 [英] Update parent version in a maven project's module

查看:602
本文介绍了在Maven项目的模块中更新父版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个奇怪的情况下,我有一个项目"Y",并且它有一个模块"X"以及其他一些模块.

I've a strange scenario where I have a project "Y" and it has a module "X" and some other modules as well.

X是项目Y的一部分,但是未链接为该项目的模块.因此,每次发布较新版本的Y时,都需要手动更新X中的父版本.

X is part of a project Y however it is not linked as a module of that project. Because of that, each time a newer version of Y is released someone needs to manually update the parent version in X.

我需要以以下方式更新Y项目: a)每次发布Y项目时,TeamCity应自动更新X中的父项目版本(与其他模块类似)

I need to update the Y project in such a way that: a)each time the Y project is released, the parent project version in X should be automatically updated by TeamCity (in a similar way as for other modules)

b)X一定不能成为Y分布的一部分

b)X must not be a part of Y distribution

c)一旦部署在TeamCity中,它就不应从X运行测试(它们应与集成测试和发布版本一起运行)

c)Once deployed in TeamCity, it should not run tests from X (they should be run with Integration tests and Release builds)

推荐答案

versions:update-parent

如果在项目X的根目录中打开终端,则可以使用versions:update-parent将其父版本更新为latest:

versions:update-parent

If you open a terminal at the root of your project X, you can use versions:update-parent to update its parent version to the latest:

$ mvn versions:update-parent -DallowSnapshots=true

您可以从TeamCity执行此命令,然后将更改提交到pom.构建Y时肯定可以触发此操作,您甚至可以提供版本(它必须是listrange):

You can execute this command from TeamCity and then commit the changes to the pom. This can certainly be triggered when Y is built, you could even provide the version (it must be a list or a range):

$ mvn versions:update-parent -DparentVersion=[1.0.0,1.0.1]    //or [1.0.0,1.5.0)

文档

请参见 versions-maven-plugin 的文档,尤其是:

Documentation

See versions-maven-plugin's documentation, especially:

  • versions:update-parent

更新项目的上级部分,以便它引用 最新可用版本.例如,如果您使用公司根目录 POM,如果您需要确保使用的是 公司根POM的最新版本.

updates the parent section of a project so that it references the newest available version. For example, if you use a corporate root POM, this goal can be helpful if you need to ensure you are using the latest version of the corporate root POM.

  • versions:set

    • versions:set

    • 可用于从命令行设置项目版本.

      can be used to set the project version from the command line.

      • versions:commit

        • versions:commit

        • 删除pom.xml.versionsBackup

          removes the pom.xml.versionsBackup

          • versions:update-child-modules

            • versions:update-child-modules

            • 更新项目子模块的父部分,因此 版本与当前项目的版本匹配.例如,如果 您有一个聚合器pom,它也是项目的父级 它聚合并且子版本和父版本脱离 同步,此mojo可以帮助修复子模块的版本. (笔记 您可能需要使用-N选项调用Maven才能运行此命令 目标是如果您的项目被严重破坏以至于无法建立,因为 版本不匹配).

              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项目的模块中更新父版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆