Eliminate Maven POM redundancy

╄→尐↘猪︶ㄣ 提交于 2019-12-04 10:41:42
Pascal Thivent

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

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).

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

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.

khmarbaise

You shouldn't define a version... in the child module, but you have to give that in the parent definition...

+--- root
      +--- pom.xml (Parent)
      +--- module1
             +-- pom.xml (child 1)

You should also define a relativePath in your childs as well...

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

If you done so you should never change the version number by hand in your parent...let the release plugin do the work it will change the version entries in all childs (parents) appropietaley...if you really need to change things sometimes use the maven-version-plugin...

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!