消除Maven POM冗余 [英] Eliminate Maven POM redundancy

查看:162
本文介绍了消除Maven POM冗余的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有以下配置的父POM

I have a parent POM with the following config

<groupId>com.example</groupId>
<artifactId>parent</artifactId>
<version>1.2-SNAPSHOT</version>

从该父POM继承的每个子项目都具有如下配置:

Each child project which inherits from this parent POM, has a config such as the following:

<parent>
    <groupId>com.amadeus.jcp.ui.skinning.skinning-system</groupId>
    <artifactId>parent</artifactId>
    <version>1.2-SNAPSHOT</version>
</parent>

我希望所有这些项目版本号都保持同步.目前,如果将父版本更改为1.3,则必须将所有子项目版本更改为1.3.有什么办法可以避免在所有子项目中重复版本号?

I want all these project version numbers to stay in synch. At the moment, if I change the parent version to 1.3, I then have to go change all the child project versions to 1.3. Is there any way I can avoid duplicating the version numbers in all the child projects?

我尝试将以上内容替换为

I tried replacing the above with

<parent>
    <groupId>com.amadeus.jcp.ui.skinning.skinning-system</groupId>
    <artifactId>parent</artifactId>
</parent>

<parent>
    <groupId>com.amadeus.jcp.ui.skinning.skinning-system</groupId>
    <artifactId>parent</artifactId>
    <version>${project.version}</version>
</parent>

但是这些都不起作用.我正在使用Maven 2.1.0版.

But neither of these work. I'm using Maven version 2.1.0.

谢谢, 唐

推荐答案

我尝试用(...)和(...)替换以上内容,但这些都不起作用.我正在使用Maven 2.1.0版.

I tried replacing the above with (...) and (...) but neither of these work. I'm using Maven version 2.1.0.

不可能.使用Maven 2.x,必须在子模块中声明parent元素,并且parent元素必须包含硬编码的version(您不能忽略它,也不能使用属性,请参见之前的答案

Not possible. With Maven 2.x, you must declare the parent element in child module and the parent element must include a hard-coded version (you can't omit it and you can't use a property, see this previous answer and MNG-624).

但是,Maven 3.1将支持无版本父元素(请参见先前的答案).

However, Maven 3.1 will supports versionless parent elements (see this previous answer).

同时,某些插件可以使维护变得更容易,例如 Maven版本插件版本Maven插件及其

Meanwhile, some plugin can make the maintenance a bit easier like the Maven Release Plugin or the Versions Maven Plugin and its versions:set or versions:update-child-modules goals.

这篇关于消除Maven POM冗余的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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