Another option is to create a deps.edn
file in the folder where you plan to run the REPL or where you keep your project files.
This file is used to inform Clojure about dependencies, source files, execution profiles, etc… It's loaded when you run a REPL (but there are other use cases) and it's supported by the core of Clojure and it's officially documented on https://clojure.org/reference/deps_and_cli
In your case you may just want to put something like the following, to declare what dependencies you want to download and put on the Java classpath.
{
:deps {
the.dependency/you-want {:mvn/version "1.0.0"}
}
}
In deps.edn
you can specify:
- third party dependencies (eg JARs) that can be already saved locally, or hosted on a Maven repository, or on Git repository…
- source paths, where your source code resides, if any
Note that the dependencies will be downloaded and cached in .cpcache/
folder, beside the deps.edn
itself. I'm not sure if you can instruct it to use the global ~/.m2
instead.
You may find the dependency coordinates (name and latest version) on clojars.org
deps.edn
is "lighter", part of the core Clojure, if less powerful than leiningen; so maybe suited for setting up an environment for casual/exploratory coding at the REPL or CLI.
You can also have a global deps.edn
in ~/.clojure/deps.edn
where you may want to define common configurations, dependencies, etc. to be used across different projects. Specific configurations can be invoked/overridden using options on the command line.