How to import local java library in clojure? (Lein)

I am trying to use a java library (jar file) called DragonConsole, which is not located in the central or cloar maven.

I want to import this library into my clojure application, but I still can not figure out how to do it.

I tried setting up a local maven repository, but I don't think everything is correct.

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 you need other files, check out the git page .

+4
source share
3 answers

This is probably the easiest way. Do you have a ~ / .m2 directory?

1) project.clj, . :dependencies [[dragonconsole "3.0.0"]]

lein run/test/etc, maven central clojars, ~/.m2, ~/.m2/repository/dragonconsole/dragonconsole/3.0.0/

: , , (, pom ..)

2) dragonconsole ~/.m2, . ln -s /path/to/project/dragonconsole-3.0.0.jar ~/.m2/repository/dragonconsole/...

, lein run/test/etc, . , , , . , , ( , ).

lein "source", , maven central, clojars.

+4

: , , leiningen, java-. ; interop, lein jar.

lein 2, - maven, maven. jar. UNIX, , , java/maven.

:

mkdir -p ${HOME}/.local/var/lein_repo

jar :

mvn deploy:deploy-file \                                                        
    -Dfile=${name}-${version}.jar \                                             
    -DartifactId=${name} \                                                      
    -Dversion=${version} \                                                      
    -DgroupId=${name} \                                                         
    -Dpackaging=jar \                                                           
    -Durl=file:/home/djhaskin987/.local/var/lein_repo

, lein:

:repositories {"local" ~(str (.toURI (java.io.File. "/home/djhaskin987/.local/var/lein_repo")))}

, , . : clj-ga 0.1.0-SNAPSHOT local.

[ djhaskin987@localhost:~/Workspace/ulam ]$ lein deps
Retrieving org/clojure/clojure/1.5.1/clojure-1.5.1.pom from central
...
Retrieving clj-ga/clj-ga/0.1.0-SNAPSHOT/clj-ga-0.1.0-20140718.032154-1.jar from local

, , github gist.

lein-localrepo, lein, .

0

Here's a simple and simple description:

https://www.pgrs.net/2011/10/30/using-local-jars-with-leiningen/

I think the best solution in the comment is:

  • Use deployment to replace install
mvn deploy:deploy-file -Dfile=jnotify-0.94.jar -DartifactId=jnotify -Dversion=0.94 -DgroupId=jnotify -Dpackaging=jar -Durl=file:/home/xxx/maven_repository/
  • Add repo to project.clj
:repositories {"local" "file:/home/xxx/maven_repository"}
0
source

All Articles