How to fix this maven dependency hell

user :

We have a Java 8 maven project that became pretty large in the last months and the build became complicated (faulty).

The structure currently looks something like this:

git repo 1:
    module 1:
        sub-module A
            depends on: sub-module C
        sub-module B
            depends on: sub-module A

git repo 2:
    module 2:
        sub-module C
        sub-module D
            depends on: sub-module A

Here's the current build process when starting with an empty .m2 maven directory:

  • First, clean install module 2 (fails on sub-module D).
  • Then clean install module 1, clean install module 2 again.

I don't really know the name of this kind of problem or what are the standard solutions to approach this. The goal would be to be able build the project in one step.

Should we merge the two git repositories and create a big maven module for module 1 and 2?

lance-java :

It seems like you have circular/cyclic dependencies where repo1 depends on repo2 and repo2 depends on repo1, which is obviously a bad idea.

Your two options are:

  1. Put your "library" modules (module A and C) into their own, separate, git repositories to remove the circular dependencies (aka chicken-or-egg problem)
  2. Have a single (monolith) multi-module build for everything

There's pro's and con's to both approaches

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=101095&siteId=1