I have a multi-module foo project with the following POM structure:
Foo
Foo POM Structure
/pom.xml (root/'grandparent' POM) /parent-foo/pom.xml (a parent with 'foo' dependencies & configurations) /child-1/pom.xml ... /child-n/pom.xml
Inheritance Foo POM
This standard parent-child relationship has parent-foo inherits from root and child-n inherits from parent-foo .
root -> parent-foo -> child-n
This is good and good, and works great for this trivial case.
(future) Use case
Using parent-foo works for the existing use case of foo , but also checks for a future use case, which we also ported: bar .
Bar
POM panel structure
/pom.xml (root POM) /parent-bar/pom.xml (a parent with 'bar' dependencies & configurations) /child-1/pom.xml ... /child-n/pom.xml
Inheritance POM POM
root -> parent-bar -> child-n
Question
Can I get the next reactor by building without to use a workaround each time to change the POMs of child-n ? Or something like this? Or, is Maven just the wrong tool for this use case?
[INFO] ------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] root ............................................... SUCCESS [INFO] parent-foo ......................................... SUCCESS [INFO] child-1 ............................................ SUCCESS (foo parent) [INFO] ... [INFO] child-n ............................................ SUCCESS (foo parent) [INFO] parent-bar ......................................... SUCCESS [INFO] child-1 ............................................ SUCCESS (bar parent) [INFO] ... [INFO] child-n ............................................ SUCCESS (bar parent) [INFO] ------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------
Ideally, I would just like to use all this in one reactor assembly, with each child-n compiled and used with each inherited parent-* dependency. I know that this will leave my Maven repo in an undesirable state, but at least I can connect the reactor to my CI and get the confidence that my build works on both parent-* dependency platforms.
Current workaround
The current workaround is to change all parents of child-n POMs, such as:
# 1. modify all child-n POMs
Change 1:
- The noted
root POM is essentially "grandparents", for the comment by @OhadR. - It is noted that both "foo" and "bar" are more than just inheritance inheritance providers; they also provide assembly configuration - if they only provided dependencies, it would be possible to use a solution based on the Maven profile.