How to use local dependencies in Clojure?

I am developing a library and an application that uses this library.

I do not have a remote repository for this library, it is stored only in GitHub as a regular project.

In my application, I want to use this library as a dependency, I think this is such a structure:

.
├── README.md
├── project.clj
├── repo
├── src
├── target
├── libraries
│   └── my-library
└── test

which my-libraryis git submodulewith my library. How do I tell my application about this dependency?

What is the 2016 solution for this?

+4
source share
3 answers

There is no need to include lib as a submodule of git. You can let go of my library project locally.

  • my-library lein pom; lein jar; lein install. - lein install, jar pom ; ~/.m2.

  • , , project.clj :dependencies [[my-library "version"]], .

EDIT: Boot, boot pom; boot jar; boot install

+6

git Clojure. Clojure Java . Maven, Clojars ( Maven Central). , Maven .

, . Clojure Leiningen, .

Maven ( Leiningen, XML) Boot, .

+2

lein checkouts, : https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md#checkout-dependencies

dir checkouts ( src). checkouts . , clj tupelo

drwxrwxr-x 10 alan alan 4096 Jan  5 12:09 clj/
drwxrwxr-x 11 alan alan 4096 Jan  9 20:01 tupelo/

clj :

> d clj clj/* clj/checkouts/*

drwxrwxr-x 10 alan alan  4096 Jan 12 10:36 clj/
drwxrwxr-x  2 alan alan  4096 Oct 14 09:23 clj/checkouts/
lrwxrwxrwx  1 alan alan    17 Oct 30 16:44 clj/checkouts/tupelo -> /home/alan/tupelo/
drwxrwxr-x  2 alan alan  4096 Aug 31 10:05 clj/doc/
-rw-rw-r--  1 alan alan 11219 Aug 31 10:05 clj/LICENSE
-rw-rw-r--  1 alan alan   794 Jan  5 12:09 clj/project.clj
-rw-rw-r--  1 alan alan   457 Aug 31 10:05 clj/README.md
drwxrwxr-x  2 alan alan  4096 Jan  3 09:01 clj/resources/
drwxrwxr-x  3 alan alan  4096 Aug 31 10:05 clj/src/
drwxrwxr-x  8 alan alan  4096 Nov 14 16:26 clj/target/
drwxrwxr-x  3 alan alan  4096 Sep 29 22:31 clj/test/

Now, when creating a project clj, it will (always) use the source code from ~/tupeloinstead of clojars, maven, etc. This means that you do not need to do and (re) install the jar from lib tupeloevery time you make the changes you want to use in clj.

+1
source

Source: https://habr.com/ru/post/1666634/


All Articles