Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two maven projects dependent from each other

Tags:

maven

I have two projects which are dependent from each other.

Let's say project maven1 has a class A and project maven2 has a reference to class B. What I basically want is that I can compile and test project maven2 so I added maven1 as dependency to it and set the scope to provided as I don't want to include maven1 (which would be the case if I put the scope to compile e.g. leave it away) In project maven1 I added project maven2 as dependency with scope "compile" as I want it to be included during runtime.

In eclipse I get an error message for that:

A cycle was detected in the build path of project 'maven2'. The cycle consists of projects {maven1, maven2} 

Also it seems to cause some issues with eclipse but I generally wanted to ask if my configuration is valid.

Thanks for help!

like image 365
Paul Avatar asked Sep 15 '25 06:09

Paul


1 Answers

This is an issue known as cyclic dependency.

To resolve this, you should create a third maven project and refactor common code to the third project (let's name it common).

After this your maven1 and maven2 projects will both have dependency to common.

like image 145
WeMakeSoftware Avatar answered Sep 17 '25 19:09

WeMakeSoftware