Can maven projects have multiple parents?

后端 未结 6 732
我在风中等你
我在风中等你 2020-12-01 04:06

We have Java and Flex projects. We currently have 1 base pom that contains the configurations we want to use for both projects. Problem with this is: Flex projects inherit c

6条回答
  •  粉色の甜心
    2020-12-01 04:54

    Just image that pom.xml are in fact Java classes: you can have only one parent (or extends a class), but this parent can also have another parent, and so on.

    As I explained here, you must distinguish the parent and aggregation principles in Maven, which means that my-plugin would be considered as an aggregation project, not necessarily a parent project for both my-plugin-client and my-plugin-parent.

    So to summarize:

    my-plugin will define the base pom for all your projects. Then, you create two new pom projects: java-base-pom and flex-base-pom. They have both my-plugin as parent. Now, my-plugin-client will have java-base-pom as parent, while my-plugin-server will use flex-base-pom for his parent.

    This way, my-plugin-client will inherit all properties defined in the my-plugin pom.xml, and also from java-base-pom project.

提交回复
热议问题