9
votes

We have a ProjectB (only main, not tests) depend on ProjectA. ProjectA's test (not main) depends on ProjectB. We have maven produce two separate artifacts (main and test jars) for each project. So there is really no circular dependency here but maven complains about circular dependency. I am wondering if there there is a way to tell in maven that this is really not a circular dependency.

In ProjectA we have dependency section of ProjectB with "test" scope since only ProjectA tests depend on ProjectB.

1
Have a look here: stackoverflow.com/a/25322753/548473 Simplest working solution!Grigory Kislin

1 Answers

6
votes

Maven builds modules as a whole, so you can't have :

Building Project A (main)
Building Project B (main)
Building Project A (test)
Building Project B (test)

You can either group your code in one project or create a third project that will have all common code for projects A and B.