1

I know that you cannot inherit two parent POMs, but I need to get around a situation where I would need just that.

In short, the situation is: Company A requires every project to use the company parent POM. Some plugins/configurations are essential so that the resulting artifacts can be used on company servers. Company A now has several projects built upon a framework of company B. Unfortunately, company B does not only provide dependencies and plugins, but needs the company B parent POM to build correctly.

So obviously, we would need a merge of two parent POMs, and not just once, but continuously with the parent POMs of company A and company B evolving over time. Maven does not provide a mechanism for this.

I wonder what would be a good solution. My best idea so far is to put essential parts of one parent POM into a profile and write a script or Maven plugin that copies this profile from one parent POM to the other. Maybe it would also be feasible to add the profile through a Maven extension, but I have never written one.

But maybe there is a good solution for the problem above, and I have just overlooked it. Can you provide one?

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • In maven < 3, there was `profiles.xml` ([link](https://maven.apache.org/guides/introduction/introduction-to-profiles.html#what-are-the-different-types-of-profile-where-is-each-defined)), but nowadays your only option (to duplicating) seems to: maintain a settings.xml(.template) (which you'd version and use through dev->ci... with `mvn -s` option) – xerx593 Mar 09 '23 at 13:37
  • 1
    @xerx593 The profiles in the `settings.xml` do not allow you to configure plugins, AFAIK. https://maven.apache.org/guides/introduction/introduction-to-profiles.html#profiles-in-external-files – J Fabian Meier Mar 09 '23 at 14:11

0 Answers0