'Bazel build on cycle in dependency graph error

I am doing a bazel build for my project,i created a java_library rule and used at different places. but I am having this cycle in dependency graph:

  ERROR: /Users/git/.../BUILD:11:1: java_library rule //B: cycle in dependency graph:
        //A.class
    .-> //B.class
    |   //C.class
    |   //D.class
    `-- //B.class
This cycle occurred because of a configuration option

This is because class B have method need call class D, and class D is also calling class B several times. can i break this cycle, i can not remove remove B from any of BUILD files



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source