Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I mix parent POMs in a Maven multi-module build?

I have a Maven multi-module project and I need two different parent POMs in this build. The first one is the real parent POM for most modules in the project but one module is a demo project which uses the parent POM of a completely different project (because it's a demo how to use my project to generate code for the second project).

The build works but I get a warning:

[WARNING] 
[WARNING] Some problems were encountered while building the effective model for my_project:my_project.demo:jar:5.0.0-SNAPSHOT
[WARNING] 'parent.relativePath' points at my_project:parent instead of other_project:parent, please verify your project structure @ line 5, column 10
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 

Since other_project is not really a module of my build, it can be anywhere. This means I can't give a relative path.

How can I fix this warning?

like image 638
Aaron Digulla Avatar asked Dec 07 '25 21:12

Aaron Digulla


1 Answers

The solution in this case is to set the relativePath to nothing to overwrite the default ../pom.xml:

<relativePath/>
  • Discussion
  • MNG-4687 - Maven should not warn about incorrect parent path when no relativePath is specified)
  • MNG-2026 - Document how parent-child POM relationships, , and works
like image 108
Aaron Digulla Avatar answered Dec 12 '25 06:12

Aaron Digulla



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!