Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does `lein deps' work?

Can anyone tell me how lein deps works? If lein finds the dependency, which is the required version for a project, in ~/.m2, will lein still download the same package again?

like image 436
Daniel Wu Avatar asked Jan 29 '15 22:01

Daniel Wu


1 Answers

Lets break this up into several questions and I'll try to give a brief idea of each:

  • Any people tell me how lein deps works?
    The goal of the "deps" target is to ensure that every dependency required to run this project is available in your local maven repo. In short it populates ~/.m2/... with jars that need to be on the class-path for the project to run

  • If lein finds the dependency, which is the required version of a project, in ~/.m2, will lein still download the same package again?
    no, it only downloads things as required and not in the local repo. By default though lein only checks for new snapshot versions once in 24 hours you can make it do this more often by running "lein -U deps"

Once lein deps has finished and the packages are available then lein can start the jvm by passing the locations of each of the required jars as classpath parameters like so:

java -classpath /project/path/test:/project/path/src:
               /project/path/dev-resources:/project/path/resources: 
               /project/path/target/classes:
               /home/ubuntu/.m2/repository/org/apache/maven/maven-model-builder/3.0.4/maven-model-builder-3.0.4.jar:
               /home/ubuntu/.m2/repository/org/apache/maven/maven-repository-metadata/3.0.4/maven-repository-metadata-3.0.4.jar: 
               /home/ubuntu/.m2/repository/org/apache/maven/wagon
               :/home/ubuntu/.m2/repository/org/clojure/tools.analyzer/0.1.0-beta12/tools.analyzer-0.1.0-beta12.jar:
               /home/ubuntu/.m2/repository/org/tcrawley/dynapath/0.2.3
               ... lots more paths here ...

Long ago lein used to copy them to a local folder in the project, it no longer does this and you are safe ignoring any documentation that tells you to run "lein clean" (though it can't hurt to run it if you are trying to clean up strange failures after AOT compilation)

like image 81
Arthur Ulfeldt Avatar answered Nov 16 '22 04:11

Arthur Ulfeldt