Maven Single Parent

We prefer repositories produce one artifact. Maven uses a declarative object model to represent these artifacts.

Common Maven project hierarchies present a problem; neither a folder based inheritance or a functional inheritance are very good. Projects are all about reuse by composition but the default tooling does not give you enough power.

We can fix it easily with Maven Tiles

With the use of https://github.com/repaint-io/maven-tiles for plugin definitions and composition projects for dependencies there is only ever a need for a single parent for your projects.

Key features of the single parent

The single parent is used to

  • set the default tiles
  • declare the standard extensions
  • set other configuration that cannot go in tiles

Artifact naming schedule

It is natural to apply object oriented analysis to Maven hierarchies.

Inheritance is not the answer

We know that inheritance is a slippery slope and if you are trying to use it for reusing behaviors then you are probably going to encounter issues.

“The dual purpose of inheritance in most current OOP languages is, I believe, the cause of most confusion. Many people think that “code reuse” is the primary purpose of inheritance, but that is not its only purpose. An overemphasis on reuse can lead to tragically flawed designs.”

Source: Composition vs. Inheritance: How to Choose? — Thoughtworks

Rate of change

The single parent will be unlikely to change for the lifetime of your project.