I'm trying to use a java library (jar file) called DragonConsole that is not on maven central or clojars.
I want to import this library in my clojure application, but so far I can't figure out how to do so.
I tried setting up a local maven repo, but I don't think I did it right.
lein deps
gives me this error:
(Retrieving dragonconsole/dragonconsole/3.0.0/dragonconsole-3.0.0.pom from local)
(Could not transfer artifact dragonconsole:dragonconsole:pom:3.0.0 from/to local)
(file:/home/michael/clj/enclojed/maven_repository/): no supported algorithms found)
project.clj:
:dependencies [[org.clojure/clojure "1.6.0"]
[clojure-lanterna "0.9.4"]
[dragonconsole "3.0.0"]]
:repositories [["local" {:url ~(str (.toURI (java.io.File. "maven_repository")))}]]
project folder:
maven_repository/DragonConsolev3.jar
maven_repository/dragonconsole/dragonconsole/maven-metadata-local.xml
maven_repository/dragonconsole/dragonconsole/3.0.0/dragonconsole-3.0.0.pom
doc/...
src/...
test/...
resources/...
project.clj
If there's any other files you need to see, check the git page.
Leiningen is a modern build system for our Clojure projects. It's also written and configured entirely in Clojure. It works similarly to Maven, giving us a declarative configuration that describes our project, without needing to configure exact steps to be executed.
This is probably the easiest way. Do you have a ~/.m2 directory?
1) Add your dependency in project.clj
e.g. :dependencies [[dragonconsole "3.0.0"]]
When you run lein run/test/etc
it will attempt to pull the library from maven central and clojars, and it will create a path for you under ~/.m2, such as ~/.m2/repository/dragonconsole/dragonconsole/3.0.0/
Note: if a library with the same name and version exists, simply delete the contents downloaded (a jar, pom, etc...)
2) Create a symbolic link to your jar under the dragonconsole directory in ~/.m2, e.g. ln -s /path/to/project/dragonconsole-3.0.0.jar ~/.m2/repository/dragonconsole/...
This time when you run lein run/test/etc
it will work. This is the easiest and cleanest approach I've found although I haven't had much time to poke around. I like it because your code and build process doesn't change any more than it needs to (just a single line to add the dependency).
For production I'd look for a way to add a lein repository "source", so it looks in my custom repo, then maven central, then clojars.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With