How to use a local repository for a Clojure librar

2020-07-03 04:52发布

问题:

I have a question about developing a Clojure library which is not answered in the suggested workflow for Library Development and Distribution as described here: http://clojure-doc.org/articles/ecosystem/libraries_authoring.html

I am developing a library and want to test this in a clojure project. In this project I will have to add the library under development as a dependency. Is there an alternative for 'lein deploy clojars' which will deploy my library to a local repository? If so how would I setup :dependencies for this in the test project? Note that I will be using libraries in clojars as well in the project which I use to test the library under development.

So where should I deploy a Clojure library in development to, a local repository perhaps, such that it can be used by projects which alpha test the library. How should the test projects address this. I would like to know how this affects 1) the project.clj file for the library development project and 2) the project.clj file for the project which tests the library in development.

回答1:

lein install does the job:

$ lein install -h
Install jar and pom to the local repository; typically ~/.m2.

In your library project execute lein install and your library jar and pom files will be installed under the ~/.m2 directory.

After that when you build another project that depends on your library, lein will find its binaries in ~/.m2.

~/.m2 is a default location of the local Maven repository which is one of the locations used by lein during dependency resolution. It also works as a cache for remote repositories where artifacts downloaded from Maven Central or Clojars are stored.



回答2:

What you are looking for is Leigningen's hard to find unless you know what to look for "checkouts" features.

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