Paul
Paul

Reputation: 419

Two maven projects dependent from each other

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!

Upvotes: 4

Views: 3603

Answers (1)

WeMakeSoftware
WeMakeSoftware

Reputation: 9162

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.

Upvotes: 7

Related Questions