Liking cljdoc? Tell your friends :D

Clojars Project

clj-depend

A Clojure namespace dependency analyzer.

Usage

Leiningen

To run clj-depend from Leiningen, check lein-clj-depend plugin.

Clojure CLI (tools.deps)

Add clj-depend as a dependency, preferably under an alias in deps.edn.

{:deps { ,,, }
 :aliases {:clj-depend {:extra-deps {com.fabiodomingues/clj-depend {:mvn/version "0.9.1"}}
                        :main-opts ["-m" "clj-depend.main"]}}}

Run:

clj -M:clj-depend

API

You can use the namespace clj-depend.api to have access to all clj-depend features.

Configuration

To let clj-depend know the existing layers in your application and the allowed dependencies between these layers, create a .clj-depend directory at the root of the project and inside it a config.edn file.

More details.

Layer Checks

Diagram to exemplify the dependency between layers:

graph TD
    A[foo.controller] --> B[foo.logic]
    A --> C[foo.model]
    B --> C

Configuration file (.clj-depend/config.edn) for diagram above:

{:source-paths #{"src"}
 :layers {:controller {:defined-by         ".*\\.controller\\..*"
                       :accesses-layers #{:logic :model}}
          :logic      {:defined-by         ".*\\.logic\\..*"
                       :accesses-layers #{:model}}
          :model      {:defined-by         ".*\\.model\\..*"
                       :accesses-layers #{}}}}

Circular Dependency Checks

Diagram to exemplify the circular dependency between namespaces:

graph TD
    A[foo.controllers.user] --> B[foo.controllers.customer]
    B --> A

Can you improve this documentation? These fine people already did:
Fábio Domingues & Fabio Domingues
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close