Maven更新版本的模块以及使用该模块的模块中的依赖项 [英] Maven uppdate version of module and dependencies in modules that use it

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

问题描述

我正在努力更新模块版本。
我的项目很大(大约50个模块),但我将其简化为一个示例。

I'm struggling with updating version of module. My project is huge (around 50 modules) but I will simplify it for an example purpouse.

-moduleA
  -moduleA1
    -pom.xml
  -pom.xml
-moduleB
  -moduleB1
    -pom.xml
  -pom.xml
-pom.xml

我想做什么。
假设每个pom.xml中都有一个版本-5.0.0。
ModuleA1 pomx看起来像:

What I want to do. Lets's assume one version in every pom.xml - 5.0.0. ModuleA1 pomx looks like:

<parent>
    <groupId>com.sample.project</groupId>
    <artifactId>moduleA</artifactId>
    <version>5.0.0</version>
</parent>
<groupId>com.sample.project.moduleA</groupId>
<artifactId>moduleA1</artifactId>
<version>5.0.0</version>

现在我想增加moduleA1的版本。
所以...

Now I want to increase version of moduleA1. So...

mvn -N versions:set -DnewVersion=5.0.1 -DgroupId=com.sample.project.moduleA -DartifactId=moduleA1

ModuleB1依赖于moduleA1

ModuleB1 has dependency to moduleA1

<parent>
    <groupId>com.sample.project</groupId>
    <artifactId>moduleB1</artifactId>
    <version>5.0.0</version>
</parent>
<groupId>com.sample.project</groupId>
<artifactId>moduleB1</artifactId>
<version>5.0.0</version>
<dependency>
        <groupId>com.sample.project.moduleA</groupId>
        <artifactId>moduleA1</artifactId>
        <version>5.0.0</version>
</dependency>

此依赖项的版本应进行更新,但这仅是第一次*版本为与父母相同)。如果我想将其更新为5.0.2,则此依存关系将不会更改,它将保持为5.0.1(仅将指向的moduleA1更新为5.0.2)
我尝试使用dependencyManegement,但结果完全相同。
有什么想法如何强制Maven更新指向的模块及其模块在其他模块上的依赖关系?

Version of this dependency should be updated and it is but only for the first time *when version is the same as parent). If I want to update it to 5.0.2 this dependency will not be changed it will stay 5.0.1 (only pointed moduleA1 will be updated to 5.0.2) I tried to use dependencyManegement but the result was exactly the same. Any ideas how to force maven to update pointed module and dependencies of its module on other modules?

推荐答案

最后,我找到了解决方案。
关键是将oldVersion参数设置为以前的版本。否则,version:set将使用$ {project.version},这是第一次更新版本,因为模块版本与project.version相同。

Finally I found the solution. The key is to set oldVersion parameter to the previous version. Otherwise version:set will use ${project.version} and that's way updating version work for the first time because module version is the same as project.version.

这篇关于Maven更新版本的模块以及使用该模块的模块中的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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