How can I install Leiningen packages behind a firewall?

前端 未结 1 2042
灰色年华
灰色年华 2020-12-11 13:13

I use a local library to do some development, but the firewall prevents alot of internet sites. Is there a way to download artifacts manually?

My project.clj is:

相关标签:
1条回答
  • 2020-12-11 13:39

    Dependency Tree

    In order to figure out which jars your project needs you can do:

    $ lein deps :tree
    

    Which will show you something that is called a "dependency tree". It will look similar to:

     [clj-time "0.5.0"]
       [joda-time "2.2"]
     [clojure-complete "0.2.3"]
     [org.myproject/some-proto "0.0.1-20130523.145830-9"]
       [org.flatland/protobuf "0.7.2"]
         [ordered-collections "0.4.0"]
         [org.flatland/schematic "0.1.0"]
         [org.flatland/useful "0.9.0"]
     [com.datomic/datomic-free "0.8.3862"]
       ...
    

    Installing Jars with Lein

    One simple way to install manually downloaded jars would be to use "lein-localrepo":

    $ lein localrepo install [-r repo-path] 
                             [-p pom-file] 
                             <filename> 
                             <[groupId/]artifactId> 
                             <version>
    

    Here are a couple of examples (given that you have downloaded the jars):

    $ lein localrepo install foo-1.0.6.jar com.example/foo 1.0.6
    
    $ lein localrepo install foomatic-1.3.9.jar foomatic 1.3.9
    

    Take a look at the documentation for more features and examples.

    Installing lein-localrepo

    You can install lein-localrepo as a plugin by adding the following to your ~/.lein/profiles.clj:

    {:user {:plugins [[lein-localrepo "0.5.2"]]}}
    

    Lein Behind a Proxy Server

    In case it is "ok" to use a proxy server, you can add it to ~/.lein/profiles.clj under jvm-opts

    {:user {:jvm-opts ["-Dhttp.proxyHost=168.1.1.104" "-Dhttp.proxyPort=8080"]}}
    

    where user is a profile name to use.

    Or you can export http_proxy environment variable before launching lein.

    0 讨论(0)
提交回复
热议问题