Working around maven error: Project ‘XYZ’ is duplicated in the reactor

maven-2

I'm creating a multi-module project that builds many other, related projects. Some of these projects are multi-module projects as well, and in some cases they build the same sub-project. Maven yells at me, but this is intentional and I'd like it to build anyway.

Has anyone worked around this?
Thanks.

Best Answer

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