I have two module A and B. Actualy B is plugin to A.
B depends on A in compile time. A NOT depend on B.
On A runtime I want to add B to classpath, so in A's pom.xml I add the following dependency
pom.xml
<dependency>
<groupId>my_group</groupId>
<artifactId>my_Plugin</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
Maven process fail with cyclic dependency error
[ERROR] The projects in the reactor contain a cyclic reference: Edge between 'Vertex{label='A'}' and 'Vertex{label='B'}' introduces to cycle in the graph B-->A-->B -> [Help 1]
[ERROR]
Why runtime dependency impact compile time ?
As suggested by Conan and if possible extract your common code into a separate module in order to resolve the cyclicity. Normally, in such cases one would extract common interfaces and the core classes into a separate module which is extended by both modules which cause the cyclic dependency. You would then remove the direct dependencies on the modules which were initially in a cyclic state. Sometimes this is very hard to solve, but modularizing the code helps you figure out how to refactor your code so that it is easily re-usable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With