Skip Navigation
Resources Blog HOW-TO: Merge Sub-Items From Parent POM to Child POM in a ...

HOW-TO: Merge Sub-Items From Parent POM to Child POM in a Maven Plugin Configuration

Cross-Posted from my buildchimp blog: I just ran into a bug report about this, so I thought it might be a good idea to post about it. The bug report detailed a case where the following configurations were not being merged correctly: Parent POM: configuration items itemone/item itemtwo/item /items /configuration Child POM: configuration items itemthree/item /items /configuration Expected result, according to MNG-2591: configuration items itemone/item itemtwo/item itemthree/item /items /configuration By default, Maven would simply replace the parent's items sub-elements with those from the child, resulting in only one item: three. This is mainly because Maven treats all plugin configuration as XML DOM content, without any idea of what makes up a list of related items, and what is just complex configuration. Moreover, sometimes you want to override the entire list instead of merely appending to it...it's a difficult balance to strike. However, Maven ...

Picture of Tim OBrien

Written by Tim OBrien

Tim is a Software Architect with experience in all aspects of software development from project inception to developing scaleable production architectures for large-scale systems during critical, high-risk events such as Black Friday. He has helped many organizations ranging from small startups to Fortune 100 companies take a more strategic approach to adopting and evaluating technology and managing the risks associated with change.