简体   繁体   English

如何让Leiningen下载所需库的来源?

[英]How do I make Leiningen download the source of a required library?

I think there is some option in the project.clj but I did not find it in the documentation of Leiningen. 我认为project.clj有一些选项,但我没有在Leiningen的文档中找到它。

For example i have this project.clj 例如,我有这个project.clj

(defproject test-app "0.1.0-SNAPSHOT"
            :dependencies [[org.clojure/clojure "1.4.0"]
                           [noir "1.3.0-beta3"]]

How can I make Leiningen download the source of noir? 如何让Leiningen下载黑色的来源? I just have the binaries now. 我现在只有二进制文件。

noir consists of clj files and they are themselves sources. noir由clj文件组成,它们本身就是源代码。 So retrieve jar: $HOME/.m2/repository/noir/noir/1.3.0-beta3/noir-1.3.0-beta3.jar , unpack it and check. 所以检索jar: $HOME/.m2/repository/noir/noir/1.3.0-beta3/noir-1.3.0-beta3.jar ,解压缩并检查。 You also can check sources of methods in REPL using source method. 您还可以使用source方法检查REPL中的方法
If you need sources of java libs then you may have problems. 如果您需要java库的源代码,那么您可能会遇到问题。 I'm not sure lein supports downloading of sources out of the box. 我不确定lein支持开箱即用的源代码下载。 If you need to download sources of java libs then you can use maven: 如果你需要下载java libs的源代码,那么你可以使用maven:

  1. Generate pom file: lein pom 生成pom文件: lein pom
  2. Download source via mvn dependency:sources : Get source JARs from Maven repository 通过mvn dependency:sources下载源mvn dependency:sources从Maven存储库获取源JAR
  3. Sources will be downloaded to your local maven repo under $HOME/.m2/repository 源将被下载到$HOME/.m2/repository下的本地maven $HOME/.m2/repository

I found a leiningen plugin called ubersource very handy. 我发现了一个名为ubersource的leiningen插件非常方便。

Just add it to your project.clj: 只需将其添加到project.clj:

:plugins [[lein-cljsbuild "1.0.1"]
          [lein-ubersource "0.1.1"]]

and then call: lein ubersource 然后打电话给: lein ubersource

You can grab the jar yourself, manually, from http://clojars.org/repo/ . 您可以从http://clojars.org/repo/手动抓住罐子。 Then unpack it and have a look around. 然后打开包装并环顾四周。

And, of course, you can go right to the source of a given lib, if you like (the Clojars page should display the url). 当然,如果你愿意,你可以直接找到给定lib的源代码(Clojars页面应该显示url)。

Incidentally though, do note that noir is deprecated, and it's recommended that you instead use Compojure + lib-noir. 顺便提一下,请注意不推荐使用noir,建议你改用Compojure + lib-noir。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM