Decycle detects circular dependencies within packages or slices in a Java (or JVM language) project. Having Decycle as a guard in your project prevents cycles and will help keeping your code base clean and modular.
Decycle is based on the ideas of Degraph that was created by Jens Schauder.
Decycle provides the following core features:
- it works with a minimal configuration – using just the default settings will find cycles between the packages of your project
- it provides a visualization of the detected package (and slice) dependencies that helps to understand, which classes are responsible for a certain dependency
- it allows the definition of custom slicings and additional dependency constraints
The following example shows a package dependency graph created by Decycle. It is cycle free (all dependency arcs are on the right side and go downwards). Hovering over a package will display all incoming and outgoing dependencies. The width of each arc corresponds to the number of the underlying class dependencies. Hovering over a dependency arc will show these class dependencies.
Dependencies creating cycles would be displayed as arcs going upwards on the left side of the package blocks.
Decycle requires Java 11 or above. The recommended way of integrating Decycle is by using the Gradle or Maven plugins.
There are specific sections in the Gradle and Maven plugin README files for configuring Decycle.
Moreover, there are separate pages about slicings, the pattern syntax that is used heavily in the configuration, and the limitations of Decycle.
- decycle-gradle-plugin is a Gradle plugin that performs Decycle checks of the project sources within a gradle build.
- decycle-maven-plugin is a Maven plugin that performs Decycle checks of the project sources within the maven verify phase.
- decycle-lib is the core library used by both plugins that might also be used within other JVM projects, however currently it is not recommended doing so as the API is not stable yet.
Compile and test the Decycle project
gradlew build
Publish local versions of the current build to maven local
gradlew publishToMavenLocal