Reputation: 1274
Everywhere I see, it is suggested that I add :dependencies
in project.clj
and run lein deps
. Where are these downloaded? What is my CLASSPATH
and how can I add my own JARs to my clojure project?
While the answer for
Dependencies in maven local repositories with leiningen
kind of solves my need, I am not marking it duplicate as what I am asking is much simpler (being a beginner, who does not have much experience with Java to know about Maven). I am still finding it hard to understand where clojure ends and leiningen begins.
The thing I was looking for is a way to add library like we do in most other languages (e.g. copy JAR to project directory and import in code).
Upvotes: 5
Views: 2577
Reputation: 301
Run lein install
from your library's project dir.
Add an entry to :dependencies
in client's project.clj
.
Make sure the lib name/version and its reference match (eg. [mylib "0.0.1-SNAPSHOT"]
).
Hope this helps, forget about jar loc and cp for now.
Upvotes: 0
Reputation: 4713
This is great question since it's not clear at all. Leiningen is often a black hole and if something isn't working it's often hard to debug.
I just recently had to do some manual scripting and leiningen does help you with finding out these things.
Where are these downloaded?
The directory is in $HOME/.m2
. This is Maven's: http://maven.apache.org/settings.html
What is my classpath?
The classpath is set depending on your :dependencies
as well as your :source-paths
and :resource-paths
vectors.
You can find out your classpath like this:
lein classpath
This will print a huge list depending on your configuration.
You could --for instance-- then run a script:
java -cp cljs-1.7.xx.jar:scripts:$(lein with-profile +dev-cljs classpath) clojure.main scripts/cljs-build.clj dev
That has access to all your projects dependencies and loads them properly.
Although you could use lein run
to achieve something similar:
lein with-profile +dev-cljs run -m clojure.main scripts/cljs-build.clj dev
How do I add my own JARs?
See: leiningen - how to add dependencies for local jars?
Upvotes: 5