5

我试图了解如何将 lein 与 clojure 一起使用并让它在 Win7 x64 上下载正确的 .jar 文件。作为一个具体的例子,我正在尝试使用 JFreeChart 和 Dejcartes。

我的问题是通用的,并不特定于 JfreeChart。我基本上不明白如何缩小看到使用某些特定包的示例与通过 lein 为我提供该包之间的差距。希望有人可以以适用于其他软件包的方式回答。

请参阅此链接:https ://github.com/markmfredrickson/dejcartes/blob/master/Readme.txt 我的 project.clj 是这样的(注释掉这篇文章的最后两行)。

(defproject monty "1.0.0-SNAPSHOT"
  :description "Monty Game Challenge"
  :dependencies [[org.clojure/clojure "1.2.1"]
                 [org.clojure/clojure-contrib "1.2.0"]
                ;[org.jfree/chart "1.0.13"]])
                 [com.markmfredrickson/dejcartes "1.0.0"]])
  1. 我看到(import '(org.jfree.chart chartframe))在 Dejcartes readme.txt 中使用过,所以我认为这意味着我需要 JFreeChart 的 .jar 文件,对吧?

    我输入[org.jfree/chart "1.0.13"]了我的 project.clj 但lein deps抱怨如下:

    C:\Users\me\code\Clojure\monty>lein deps
    Downloading: org/jfree/chart/1.0.13/chart-1.0.13.pom from central
    Downloading: org/jfree/chart/1.0.13/chart-1.0.13.pom from clojure
    Downloading: org/jfree/chart/1.0.13/chart-1.0.13.pom from clojars
    Downloading: org/jfree/chart/1.0.13/chart-1.0.13.pom from central
    Downloading: org/jfree/chart/1.0.13/chart-1.0.13.jar from central
    Downloading: org/jfree/chart/1.0.13/chart-1.0.13.jar from clojure
    Downloading: org/jfree/chart/1.0.13/chart-1.0.13.jar from clojars
    Downloading: org/jfree/chart/1.0.13/chart-1.0.13.jar from central
    An error has occurred while processing the Maven artifact tasks.
    Diagnosis:
    Unable to resolve artifact: Missing:
    ----------
    1) org.jfree:chart:jar:1.0.13
    Try downloading the file manually from the project website.
    

    我想我需要直接下载 .jar 文件,但是一旦我有了 .jar 文件,我该如何哄 lein 把它放在我的类路径中,这样我就可以使用 emacs 等来处理它?

  2. Dejcartes 示例使用(require '[com.markmfredrickson.dejcartes :as chart]),所以我放入[com.markmfredrickson/dejcartes "1.0.0"]了我的 project.clj。当我运行时,这似乎开始下载一些东西,lein deps但随后它以同样的方式窒息:

    C:\Users\me\code\Clojure\monty>lein deps
    Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.pom from central
    Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.pom from clojure
    Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.pom from clojars
    Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.pom from central
    Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.jar from central
    Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.jar from clojure
    Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.jar from clojars
    Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.jar from central
    An error has occurred while processing the Maven artifact tasks.
     Diagnosis:
    
    Unable to resolve artifact: Missing:
    ----------
    1) com.markmfredrickson:dejcartes:jar:1.0.0
    
    Try downloading the file manually from the project website.        
    

    据称从 (clojars) 下载的其中一个存储库甚至没有在大列表中显示 Dejcartes。如何让 Lein 下载 Dejcartes?

  3. 最后,考虑到我想开始使用一些包,我如何让 lein 自动找到最新版本?我还没有看到任何关于此的内容,并且所有 project.clj 示例似乎都对版本进行了硬编码,例如"1.0.2"等。

非常感谢

迈克尔

4

1 回答 1

5

第一步是找出你想要获取的库的​​名称。如果它是一个 Java 库,它可能在 Maven Central 上。要找出答案,请转到Maven Central Search并搜索您想要的任何库。在这种情况下,我去那里搜索 JFreeChart。它给了我这个。你想要的罐子列在那里。它们分为三个相关部分:groupid、artifactid 和 verison。groupid 是斜线 (/) 之前的部分,artifactid 是斜线之后的部分,版本是......好吧,版本。把它放在一起,你就有了[jfree/jfreechart "1.0.13"]

如果您要查找的库是 Clojure 库,则它可能位于clojars上,在这种情况下,您需要去那里进行搜索。

要回答关于没有找到 dejcartes 的部分,那是因为它是一个古老而废弃的图书馆,不受 leiningen、cake、maven 或其他任何东西的管理。它不在任何 Maven 存储库中。除非你自己把它放在那里,否则你将无法在那里找到它,这完全是一个完全不同的问题。

为了回答你的第三个问题,leiningen 的search任务是搜索各种 repos 的东西。Cake 目前有一个类似的搜索 clojars 的东西,但我可能会根据更一般的 Leiningen 代码重写它。

于 2011-10-25T10:04:10.777 回答