Adding dependencies in Leinningen
See the clojure docs for require. Here's an example where the namespace is given the alias
r so that you can shorten the names.
(require [interview.prompts.rawlist :as r]) (r/your-function)
You can also refer to the full name at any time too:
There are many ways to use require, e.g. with refer if you don't want a prefix. Say you have 3 functions f1,f2,f3, then you can refer to them in these ways:
(require [interview.prompts.rawlist :refer [f1 f2] :as r) (f1) (f2) (r/f3)
Notice in third case, because it wasn't in the refer list, you have to use the
For test folders, read the documentation for leiningen where it is explained, but basically boils down to:
+ /interview |--+ src/ |--+ test/
and the sub-folder structure follows exactly the same pattern as the src dir.
You can add additional folders in
:test-paths keys in the main project macro. See the sample project for more information.
I recommend you absorb everything in the sample project above, and also read the leiningen tutorial.
Finally, when referring to functions in the
ns declaration in other sources (e.g. in your tests) you use the same format, but using the
(ns foo.bar (:require [interview.prompts.rawlist :as r])) (r/foo-fn)
use function also makes another libraries namespace accessible to the current one. However
use includes everything from the other library, it also makes everything part of the same namespace (ie. as if the functions, macros, name bindngs, etc were written in your library).
use function is usually avoided and
require is used instead. However, it can be convenient to make use of the 'use' function within the REPL as a way to include your project within the
user namespace. Being in the
user namespace gives you access to the REPL tools (eg.
Lets make use of the
use function to include a library called