Search code examples
clojureclojure-testing

How to require dependencies in Clojure?


I have two questions regarding dependencies in Clojure project.

  1. Is there something like :dev-dependencies or :test-dependencies so that I don't have to download them all on lein run? So until I run my tests I don't need to have these extra libraries.

  2. Can I load dependencies in one file and require this one file in an another file? I'd like to have something similar to:

    ; dependencies.clj
    ; ...
    
    (:require [clj-http.client :as client]
      [clj-http.fake   :refer :all]
      [clojure.test   :refer :all]))
    
    
    ; some-file.clj
    ; ...
    
    (:require [dependencies :refer :all[)
    

Solution

  • 1) Yes, Leiningen offers profiles for just these purposes

    2) No, referals from one namespace are not "inherited" between namespaces. You can't express "I want to refer to everything in this namespace, that some other namespace refers"