Definition of Clojure Jar Path

The purpose of this question is to eliminate confusion regarding the dependencies of Clojure project.clj and how to define local dependencies.

I have a bunch of Clojure lein projects in a tree

./projects/clojure/bene-csv # A csv parsing library ./projects/clojure/bene-cmp # A main program that depends on bene-csv 

I am editing a bene-cmp project.clj project file. I want to make a dependency on. / projects / clojure / bene-csv / bene-csv-1.0.0-SN.jar.

I use simple directory notation to indicate a path or something else

Thanks.

Edit:

I can include bene-csv in my project by typing lein install in the bene-csv project directory and using these project.clj entries in the project.clj project directory of the bene-cmp project:

 (defproject bene-cmp "1.0.0-SN" :description "This is the main benetrak/GIC comparison program." :dependencies [[org.clojure/clojure "1.3.0"] [clojure-csv/clojure-csv "1.3.2"] [bene-csv "1.0.0-SN"]]) 

However, I am still trying to understand what this path is, and I would appreciate any pointers or help in these areas. Thanks.

+7
source share
1 answer

Leinigen uses maven dependency management under the covers, so all dependencies are installed in

 ${HOME}/.m2/repository/${groupId-as-path}/${artifactId}/$[version}/${artifactId}-${version}.jar 

where for [org.clojure/clojure "1.3.0"] groupId org.clojure , artifactId is set to clojure , and version 1.3.0 . groupIds are converted to paths, so groupId from org.clojure has an org/clojure path.

Depending on the maven specified in pom.xml, this will look like this:

 <project> ... <dependencies> <dependency> <groupId>org.clojure</groupId> <artifactId>clojure</artifactId> <version>1.3.0</version> </dependency> </dependencies> ... </project> 

Note. If no groupId is specified, then leiningen uses the same value for groupId and artifactId.

The advantage of using maven dependency management is that it handles transitive dependencies for you, i.e. if you determine dependence on something, you get everything that it depends on, and everything that these things depend on, etc. etc.

Therefore, in order to depend on the local project, the right thing is to install the local project in the local repository.

To save on the endless change of versions at the development stage, maven supports SNAPSHOT dependencies, as a result of which additional information is added to the version (mainly date-time), and maven knows that, say, 1.3.1-SNAPSHOT, it should look like for the latter version of this snapshot. This is caused by the naming convention {version} -SNAPSHOT.

In maven, you can specify system dependencies with a hard-coded path, but usually this bad practice is usually used for platform-dependent things, that is, it can have its own library component.

By default, the maven central repository is searched and leinigen adds clojars to the repository , which serves as the central repo for clojure jars.

leinigen uses this material under covers and creates a path to the class, referencing the banks in your local maven repository.

Note that you can generate pom.xml from the leinigen project using lein pom . Then you could manage it. A useful feature is

 mvn dependency:tree 

which gives an idea of ​​the art of ascii of all dependencies.

+13
source

All Articles