如何从leiningen项目中排除罐子?

时间:2011-07-23 17:16:41

标签: clojure jar leiningen autodoc

在使用Leiningen时,我遇到了以下突然错误:

线程“main”中的异常java.lang.NoSuchMethodError:org.apache.tools.ant.util.FileUtils.getFileUtils()Lorg / apache / tools / ant / util / FileUtils; (core.clj:1)

我在https://github.com/technomancy/leiningen/issues/194找到了以下答案:

if ant version 1.6.1 is included in a project, lein fails. Autodoc "0.7.1" includes ant version 1.6.1.

a work around is to exclude ant.1.6.1 in the project.clj.    <--- *1*
But a better solution is changing the order of lein classpath.

from bin/lein   <--- *2*
CLASSPATH="$CLASSPATH:$LEIN_LIBS:$LEIN_DIR/src:$LEIN_DIR/classes:$LEIN_DIR/resources:$LEIN_JAR"
**changes to : **
CLASSPATH="$LEIN_LIBS:$LEIN_DIR/src:$LEIN_DIR/classes:$LEIN_DIR/resources:$LEIN_JAR;$CLASSPATH"

我在https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md阅读了Leiningen教程,在https://github.com/technomancy/leiningen/blob/stable/sample.project.clj阅读了示例project.clj文件,但我仍然有以下问题:

1)在上面标有 1 的行上,我无法告诉如何排除特定版本的jar文件。

2)在 2 ,上面,究竟是什么bin/lein?我的Leiningen项目没有bin目录,Leiningen本身就是一个脚本,所以那里没有bin目录?

非常感谢你的帮助。


附录8/6/11:对于Autodoc的具体问题,我找到了一个Autodoc的分支,为我解决了这个问题。只需将“[org.clojars.weavejester / autodoc”0.9.0“]”添加到project.clj&gt; defproject&gt; :dev-dependencies条款。然后,从命令行(目录等于你的leiningen项目的根目录),执行'lein autodoc',等待一段时间。

1 个答案:

答案 0 :(得分:11)

在回答(1)时我不确定他是否说你需要排除特定版本的Ant,但更有可能的是你可以通过排除由Autodoc引入的Ant版本来解决问题(否)无论什么版本)。你可以尝试类似的东西:

(defproject my-project "1.0.0"
  :dependencies [[org.clojure/clojure "1.2.0"]
                 [org.clojure/clojure-contrib "1.2.0"]]
  :dev-dependencies [[autodoc "0.7.1" :exclusions [org.apache.ant/ant]]])

我只是在dev-dependencies中将它排除在外,假设只在构建期间使用Autodoc。

对于(2),你是对的,Leiningen是一个脚本,但是在问题报告中,作者建议编辑Leiningen脚本以通过改变Leiningen的CLASSPATH中引用的目录的顺序来解决问题。