Inheritance

This lesson explains and demonstrates how inheritance works with POM files.

We'll cover the following...

We learned about Super POM and how all POMs extend from this base POM. Maven allows us to set any POM as the parent POM for a project. Introducing a parent POM can help extract out common configurations among an organization’s projects and consolidate them in a parent POM from which all other projects inherit. This avoids unnecessary repetition and verbosity. For example, a company can decide to have a parent POM that lists the organization’s internal Maven repositories thus allowing sub-teams to simply extend from the parent POM and not worry about the location of repositories. POM inheritance allows the following to be merged:

  • dependencies
  • developers and contributors
  • plugin lists (including reports)
  • plugin executions with matching ids
  • plugin configuration
  • resources

In essence, POM files at the bottom of the hierarchy declare that they inherit ...