Kamil Lelonek
Kamil Lelonek

Reputation: 14744

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[)
    

Upvotes: 0

Views: 282

Answers (2)

bsvingen
bsvingen

Reputation: 2759

Regarding your point 2, Potemkin can help you do this. Potemkin is especially useful if you have several namespaces implementing the functionality of a library, but then want to present a single namespace to users of the library.

Upvotes: 2

Arthur Ulfeldt
Arthur Ulfeldt

Reputation: 91534

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"

Upvotes: 3

Related Questions