Search code examples
archunit

How to allow only certain cyclic dependencies in ArchUnit?


In ArchUnit, I can check that packages .should().beFreeOfCycles(). How can I specify exceptions to this rule for certain cycles?

E.g., given these packages and their dependencies:

A <-> B <-> C

How can I allow A <-> B, but still forbid A and B being part of any other cycle, e.g. B <-> C?


Solution

  • Freezing Arch Rules is always an option to allow for certain violations, but catch others.
    Would that be feasible in your case?