Maven pom inheritance ands overriding in parent child module

守給你的承諾、 提交于 2019-12-10 22:43:09

问题


I was curious how to decide whether our element in child pom will override the parent pom detail or just get added along with the parent pom inherited elements in child pom.

Let us take an example to understand :

For example, each dependency is uniquely identified by maven coordinates. In child pom, if a dependency has maven coordinate different from dependencies in parent pom, then no overriding happens and parent dependencies are added into child pom too.

Here we had a criteria of unique identification of an element in our maven xml which helped us to identify whether or not, overriding will take place.

Another example:

Let us take another example of <license> tag. Doing some experiment using effective pom, I came to know, that <licenses> are inherited.

<licenses>
    <license>
        <name>The Apache Software License, Version 2.0</name>
        <url>http://www.apache.org/licenses/LICENSE-3.0.txt</url>
        <distribution>repo</distribution>
    </license>
</licenses>

But if I change any one of <name>, <url>, <distribution>, overriding happens.

Are there any clear cut rules when overriding happens and when it does not happen (and parent elements gets appended with child elements) without generating effective pom every time and checking it?

来源:https://stackoverflow.com/questions/55530477/maven-pom-inheritance-ands-overriding-in-parent-child-module

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