working around maven error: Project 'XYZ' is duplicated in the reactor
This happen when you have a structure like this:
+-- root-project-A
`-- pom.xml
+-- module-A
| `-- pom.xml
+-- module-B
| `-- pom.xml
+-- root-project-B
`-- pom.xml
+-- module-C
`-- pom.xml
And configure yours modules like this:
|-- root-project-A
`-- pom.xml
<modules>
<module>module-A</module>
<module>module-B</module>
<module>root-project-B</module> <!-- Error: project A reference project B -->
<module>root-project-B/module-C</module> <!-- Error: project A reference project B -->
</modules>
|-- root-project-B
`-- pom.xml
<modules>
<module>module-C</module>
</modules>
The project A cannot reference the project B, because B doesn't reference A as parent. The package must be independently
I don't think you should do that. (You could try defining a profile - let say a complete-build profile, where you make sure that every module is compiled just once, an another profile that adds the additional modules when you do a sub-build.)
But you better go the maven way - every project should include as modules only directories from its own directory, e.g. only direct children.
Maven has some non-written implicit assumptions like - always inherit submodules, from the pom in the parent directory, e.g. the inheritance tree must match your directory tree, otherwise some plugins won't work, e.g. release plugin, or some report plugins.
The short answer is - in maven you cannot have a module twice in your project hierarchy/tree.
There are a lot of wrong ways in maven, therefore one must stick to something that is known to work - like pom hierarchy == directory structure.