egervari
egervari

Reputation: 22512

Maven cyclic dependency when compling tests only - how to resolve easily?

I am working on modernizing an older project to be used with Maven. The project is very large and has around 30 modules in it.

As far as the main source code is concerned, I managed to get all of it to compile and establish the dependencies correctly. It actually works and it can be run through Maven's tomcat plugin.

The problem is with compiling the tests.

Unfortunately, this company did not apply the same dependency restrictions for their test code as they did with their main source code.

For example, C depends on B, and B depends on A in the main source code. However, A depends on C to run its tests. Obviously, Maven is going to complain and say there is a cyclic dependency.

Besides out-right fixing the code (which is sadly not going to happen on this project - it's tens of millions of lines), is there any way to tell Maven, "Please compile ALL of the main source code first, then compile ALL of the test code afterward" ? Or is there any other solution around this problem?

Thanks

Upvotes: 1

Views: 473

Answers (1)

Jean-Rémy Revy
Jean-Rémy Revy

Reputation: 5677

You might be able to cheat, playing with profile, and telling to Maven to run some tests as integration-tests ... This will ensure that all source code would be compiled (remember : validate compile test package integration-test).

I'll look for snippet conf, in order to guide you, but I don't have ones ready-to-use at this moment.

You can maybe read this thread : Maven - separate integration tests from unit tests

It's not a really clean solution, but I don't see how to solve it.

Upvotes: 1

Related Questions