如何让Lein能够与JFreeChart和Dejcartes搭配使用?

5
我正在尝试理解如何在Win7 x64上使用lein和clojure,并使其下载正确的.jar文件。以JFreeChart和Dejcartes为例。
我的问题是通用的,不特定于JFreeChart。我从根本上不明白如何弥合一个示例所使用的某个特定包之间的差距,并通过lein使该包对我可用。希望有人能以适用于其他软件包的方式回答。
请参考此链接:https://github.com/markmfredrickson/dejcartes/blob/master/Readme.txt。我的project.clj文件像这样(为了发布此帖子,注释掉了最后2行中的一个)。
(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. I see (import '(org.jfree.chart chartframe)) used in the Dejcartes readme.txt, so I think this means I need the .jar file for JFreeChart, right?

    I put [org.jfree/chart "1.0.13"] in my project.clj but lein deps complains about it as follows:

    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.
    

    I think I need to download the .jar file directly but once I have the .jar file how do I coax lein to put it in the classpath for me so I can lein swank it using emacs, etc.?

  2. The Dejcartes example uses (require '[com.markmfredrickson.dejcartes :as chart]) so I put [com.markmfredrickson/dejcartes "1.0.0"] in my project.clj. This appears to start downloading some stuff when I run lein deps but then it chokes in the same way:

    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.        
    

    One of the repositories it is allegedly downloading from (clojars) doesn't even have Dejcartes shown in the big list. How do I get Lein to download Dejcartes?

  3. Finally, given that I want to start using some package, how do I get lein to automatically find the latest version? I haven't seen anything about this and all the project.clj examples seem to hard-code the version, eg "1.0.2" etc.

非常感谢您。迈克尔。

Leiningan 在下载大文件时有时会出现故障。 我的解决方法如下:
  • 编辑 project.clj 以包括依赖项(如您已经完成)。
  • 运行 lein deps。
  • 检查是否卡住(例如,如果某个依赖项需要几分钟以上)。
  • 如果卡住,则强制终止 lein deps。
  • 重新启动。
通常如果我这样做几次,就可以让 lein deps 完成获取所有依赖项。
- jayunit100
1
另外:您能否重新命名这个问题,以便在标题中清楚地表明您正在询问什么(例如:为什么当尝试获取Dejcartes和JFree项目时Leiningan失败?) - jayunit100
我解决了这个问题。Lein不是因为下载量大而出现问题,而是因为我没有正确地使用它。 - Sonicsmooth
1个回答

5
第一步是找到你想要获取的库的名称。如果它是一个Java库,它可能在Maven中央仓库上。要找出,请前往Maven Central Search并搜索您想要的任何库。在这种情况下,我去那里搜索了JFreeChart。它给了我this。您想要的jar文件在那里列出。它们分为三个相关部分:groupid、artifactid和version。groupid是斜杠(/)之前的部分,artifactid是斜杠后面的部分,而版本则是……嗯,版本。将它们组合在一起,您就有了[jfree/jfreechart "1.0.13"]
如果您想要的库是Clojure库,则可能在clojars上,在这种情况下,您需要前往该网站并搜索。
回答关于dejcartes库找不到的问题,那是因为它是一个旧的、被弃用的库,不由leiningen、cake、maven或其他任何东西管理。 它不在任何maven存储库中。 除非你自己把它放在那里,否则你将无法在那里找到它,这完全是另一个问题。
回答你的第三个问题,leiningen有一个搜索任务,用于搜索各种仓库中的内容。 Cake目前也有类似的搜索clojars的功能,但我可能会重写它,以基于更通用的Leiningen代码。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接