EDIT: I have changed this question so that it is not simply a duplicate of Can maven projects have multiple parents? (the answers for which seems to assert that a module can't have 2 parents)
Q: Maven: can a child module of a multi-module parent project be used in another completely separate project ?
Consider a ChildCommon project that is an API module or common implementation library to be shared by many projects.
There are at least 2 possibilities:
Case1: If 2 parents are allowed (with Maven 3.3.3):
ParentA
|--ChildCommon
ParentB
|--ChildCommon
Case2: Instead of 2 parents, a completely separate project depends directly on the child module:
ParentA
|--ChildCommon
ProjectB dependsOn ChildCommon [EDIT: ANSWER IS, YES, THIS WAY WORKS]
And if so, if part of the Maven build spec for the ChildCommon module has been siphoned off (up) into ParentA, how does one ensure the correct Maven spec is used when it is used by ParentB or ProjectB (without having to repeat things from ParentA brute force) ?
[EDIT: Answer is that Maven handles that perfectly via the "externally" referenced child's parent POM.]
EDIT: Expanding: My aim is to have my POM Optimizing and Refactoring cake using a parent POM and eat it. I have a set of 6 core modules that work together to nicely achieve the modularisation I need to develop a core web app system:
CoreLib, CoreAll, CoreImp, CoreAPI, CoreEJB, CoreWeb
CoreWeb runs as a standalone web app, and can also be reused by other web apps using overlays.
I won't go into here why I need 6, but it's in fact elegant for my case. It is however wearisome having to sometimes clean and build each one. It is also error-prone repeating certain artifact versions in each pom.xml (my main concern).
A specific web app combo leverages (at least some of) the above core modules (including CoreWeb):
SpecAPI, SpecEJB, SpecWeb
But another applications (a non-web one) might leverage only a subset of the core ones such as CoreAll, CoreImp, and would not under any circumstances want coupling to, for example, CoreWeb.