Maven requires the parent to be of packaging
pom
.
You can make a pom
project behave as if it were a jar
project, by including a bunch of plugin executions and attaching them to their subsequent lifecycle phase. It's not a happy road. On the contrary, the following is.
From an object oriented standpoint, what is it that you want? You have one object that is made up out of a bunch of other objects, right? In other words composition, as opposed to inheritance.
Your final delivery is made up out of the other (jar
) projects, i.e. the other projects are dependencies of the final delivery project. You will define the other projects each as dependency
so that whomever uses your final delivery knows what (transitive) dependencies to get. Alternatively the final delivery jar
could be packaged up as "uber-jar
" and thus contain all its dependencies. That all really depends on how the final delivery is to be used.
At the same time the following two aspects (may) still exist:
- The parent project (which is different than the final delivery project, in fact it may be the parent of the final delivery project also) defines commonalities between its subsequent children, as is what you should expect from inheritance. A child is any project that refers to the parent through the
parent
configuration in its POM.
- A project that defines
modules
that are to be easily built in one go. Modules are projects that are referred by use of modules.module
. This is typically (I guess >99%) done in the parent project, but not necessarily. You could put it in the final delivery project also (without affecting inheritance, because that is thus a different beast), but it's atypical and I would not go there.